public __construct ( string $path, array $options = [] ) | ||
$path | string | Directory path for saving the log files. |
$options | array | The following options are available: - extension (string) Extension for all log files. - prefix (string) Name prefix for all log files |
public function __construct($path, array $options = [])
{
$path = rtrim($path, ' ' . \DIRECTORY_SEPARATOR);
if (!file_exists($path) || !is_dir($path)) {
throw new LoggerException('Directory ' . $path . ' does not exist!');
}
if (!is_writable($path)) {
throw new LoggerException('Directory ' . $path . ' is not writable!');
}
$this->path = $path;
$defaults = ['extension' => 'log', 'prefix' => ''];
$this->options = array_merge($defaults, $options);
}