diff --git a/README.md b/README.md index c54225d..bad1e73 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Based on https://github.com/pfote/Codeigniter-Monolog, but updating monolog to 1 This library registers Monolog as the PHP error handler to catch all errors and adds support for IntrospectionProcessor for additional meta data. -Supports File (RotatingFileHandler) and New Relic (NewRelicHandler). +Supports File (RotatingFileHandler), New Relic (NewRelicHandler) and HipChat (HipChatHandler). Installation ------------ diff --git a/application/config/monolog.php b/application/config/monolog.php index c98d971..1dae050 100644 --- a/application/config/monolog.php +++ b/application/config/monolog.php @@ -12,7 +12,7 @@ /* GENERAL OPTIONS */ -$config['handlers'] = array('file', 'new_relic'); // valid handlers are file | new_relic +$config['handlers'] = array('file', 'new_relic', 'hipchat'); // valid handlers are file | new_relic | hipchat $config['channel'] = ENVIRONMENT; // channel name which appears on each line of log $config['threshold'] = '4'; // 'ERROR' => '1', 'DEBUG' => '2', 'INFO' => '3', 'ALL' => '4' $config['introspection_processor'] = TRUE; // add some meta data such as controller and line number to log messages @@ -26,5 +26,13 @@ /* NEW RELIC OPTIONS */ $config['new_relic_app_name'] = 'App Name - ' . ENVIRONMENT; +/* HIPCHAT OPTIONS */ +$config['hipchat_app_token'] = ''; //HipChat API Token +$config['hipchat_app_room_id'] = ''; //The room that should be alerted of the message (Id or Name) +$config['hipchat_app_notification_name'] = 'Monolog'; //Name used in the "from" field +$config['hipchat_app_notify'] = false; //Trigger a notification in clients or not +$config['hipchat_app_loglevel'] = Logger::WARNING; //The minimum logging level at which this handler will be triggered + + // exclusion list for pesky messages which you may wish to temporarily suppress with strpos() match $config['exclusion_list'] = array(); diff --git a/application/libraries/Log.php b/application/libraries/Log.php index 94c9062..db5da65 100644 --- a/application/libraries/Log.php +++ b/application/libraries/Log.php @@ -16,6 +16,7 @@ use Monolog\ErrorHandler; use Monolog\Handler\RotatingFileHandler; use Monolog\Handler\NewRelicHandler; +use Monolog\Handler\HipChatHandler; use Monolog\Processor\IntrospectionProcessor; /** @@ -79,6 +80,15 @@ public function __construct() $handler = new NewRelicHandler(Logger::ERROR, true, $this->config['new_relic_app_name']); break; + case 'hipchat': + $handler = new HipChatHandler( + $config['hipchat_app_token'], + $config['hipchat_app_room_id'], + $config['hipchat_app_notification_name'], + $config['hipchat_app_notify'], + $config['hipchat_app_loglevel']); + break; + default: exit('log handler not supported: ' . $this->config['handler']); }