lithium\analysis\logger\adapter\File::__construct()

public method

Constructor.

Parameters

  • array $config

    Settings used to configure the adapter. Available options:

    • 'path' string: The directory to write log files to. Defaults to <app>/resources/tmp/logs.
    • 'timestamp' string: The date()-compatible timestamp format. Defaults to 'Y-m-d H:i:s'.
    • 'file' \Closure: A closure which accepts two parameters: an array containing the current log message details, and an array containing the File adapter's current configuration. It must then return a file name to write the log message to. The default will produce a log file name corresponding to the priority of the log message, i.e. "debug.log" or "alert.log".
    • 'format' string: A Text::insert()-compatible string that specifies how the log message should be formatted. The default format is "{:timestamp} {:message}\n".

Returns

void

Source

	public function __construct(array $config = []) {
		$defaults = [
			'path' => Libraries::get(true, 'resources') . '/tmp/logs',
			'timestamp' => 'Y-m-d H:i:s',
			'file' => function($data, $config) { return "{$data['priority']}.log"; },
			'format' => "{:timestamp} {:message}\n"
		];
		parent::__construct($config + $defaults);
	}