polyfractal/sherlock

Logging issues

Closed this issue · 2 comments

I think this should either have some way to completely disable analog logging or else allow you to specify something other than file logging. Like syslog, for example.

I just put sherlock onto a staging machine and I get this:

fopen(/path/to/my/app/vendor/sherlock/sherlock/src/Sherlock/../sherlock.log):
failed to open stream: Permission denied

Agreed, this is a problem - I'll add a setting to disable logging. Analog provides several different logging outputs (including syslog - see these examples), so I'll add some settings to expose that functionality.

Related, if you need a quick fix, you can set 'log.file' in the sherlock constructor to override the default logging directory.

Default logging state is now 'disabled'. Logging can be enabled through the Sherlock settings:

$settings['log.enabled'] = true;
$sherlock = new Sherlock($settings);

Sherlock defaults to a file logger, and logs to "../sherlock.log". The path can be changed through the settings as well:

$settings['log.enabled'] = true;
$settings['log.file'] = '../sherlock123.log';
$sherlock = new Sherlock($settings);

Finally, custom Analog handlers can be used instead of the default file handler:

$syslogHandler = \Analog\Handler\Syslog::init ('analog', 'user');

$settings['log.enabled'] = true;
$settings['log.handler'] = $syslogHandler;
$sherlock = new Sherlock($settings);