I have a simple importer class that logs success and failure statuses to a log file.
I have made the log file name a constant in the class like so:
class MyClass
{
const STATUS_LOG = "my_log.log";
public function doImport()
{
// do import here and log result
}
}
Currently i know of no reason that different logs would be used, but would it be better to allow that flexibility and do the following instead:
class MyClass
{
private $statusLog;
public function __construct($statusLog)
{
$this->statusLog = $statusLog;
}
public function getStatus()
{
return $this->statusLog;
}
public function setStatusLog($statusLog)
{
$this->statusLog = $statusLog;
}
public function doImport()
{
// do import here and log result
}
}
Given i currently have no use for different log files, is there any benefit in the second approach?