Kohana 3.3 log writer for Loggly.com
Write Kohana logs to a Loggly.com input. You need an account at loggly.com for this to work. The basic account is free, with quota limits., (*1)
Installation
As a Git submodule:
git submodule add git://github.com/anroots/kohana-loggly.git modules/loggly
{
"require": {
"anroots/kohana-loggly":"1.*"
}
}
Activate the module in bootstrap.php.
<?php
Kohana::modules(array(
...
'loggly' => MODPATH.'kohana-loggly',
));
Create a new input via the loggly.com control panel. The input should be a JSON-enable HTTPS input. The module sends logs to Loggly JSON-encoded; that means you can do some really cool stuff with that data., (*2)
, (*3)
Add the log writer after module activation
<?php
Kohana::$log->attach(new Log_Loggly('my-input-key'));
You can use the $levels and $min_level params of $log->attach to set restraints on when to log to Loggly:, (*4)
Kohana::$log->attach(new Log_Loggly('my-input-key'), Log::INFO); // Log only messages starting from level INFO (no DEBUG)
Log some data in your code
<?php
Kohana::$log->add(Log::EMERGENCY,'The world will end on :time.',[':time'=>time()+60]);
Results appear in the Loggly console
, (*5)
Licence
MIT licence, (*6)