From 2241278642459c269189d68fb1386292a062d094 Mon Sep 17 00:00:00 2001 From: Haoran Un Date: Tue, 8 Sep 2015 09:15:08 +1000 Subject: [PATCH 1/4] add HipChat integration --- application/config/monolog.php | 10 +++++++++- application/libraries/Log.php | 9 +++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/application/config/monolog.php b/application/config/monolog.php index c98d971..b37cc5c 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 $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..4998923 100644 --- a/application/libraries/Log.php +++ b/application/libraries/Log.php @@ -79,6 +79,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']); } From 6aab99b0ac7b5a94f5bbd8988fb78378e1bd5bef Mon Sep 17 00:00:00 2001 From: Haoran Un Date: Tue, 8 Sep 2015 09:17:31 +1000 Subject: [PATCH 2/4] Forgot to actually include the HipChat library. --- application/libraries/Log.php | 1 + 1 file changed, 1 insertion(+) diff --git a/application/libraries/Log.php b/application/libraries/Log.php index 4998923..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; /** From 4aa5bafc2b479803fefd3ab7f42307cc74a46d0e Mon Sep 17 00:00:00 2001 From: Haoran Un Date: Tue, 8 Sep 2015 09:17:49 +1000 Subject: [PATCH 3/4] Add Hipchat to the list of options. --- application/config/monolog.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/config/monolog.php b/application/config/monolog.php index b37cc5c..1dae050 100644 --- a/application/config/monolog.php +++ b/application/config/monolog.php @@ -12,7 +12,7 @@ /* GENERAL OPTIONS */ -$config['handlers'] = array('file', 'new_relic', 'hipchat'); // 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 From ac2f121e51c0fe3cb01f33556b3e66f9f2b9e907 Mon Sep 17 00:00:00 2001 From: Haoran Un Date: Tue, 8 Sep 2015 09:21:23 +1000 Subject: [PATCH 4/4] Update README.md with supports. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 ------------