From 9ce47620522fbf8e282888c16198545b1fa464ee Mon Sep 17 00:00:00 2001
From: manumanu <manumanu@46459.no-reply.drupal.org>
Date: Thu, 13 Jun 2013 10:44:47 +0200
Subject: [PATCH] added the HipChat handler, raised the Monolog dependency
 version.

---
 composer.json        |  2 +-
 handlers/hipchat.inc | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 monolog.monolog.inc  | 12 ++++++++++++
 3 files changed, 66 insertions(+), 1 deletion(-)
 create mode 100644 handlers/hipchat.inc

diff --git a/composer.json b/composer.json
index 16c661c..2ec7bbd 100644
--- a/composer.json
+++ b/composer.json
@@ -20,7 +20,7 @@
         "issues": "http://drupal.org/project/issues/monolog"
     },
     "require": {
-        "monolog/monolog": "~1.0"
+        "monolog/monolog": "1.6.x-dev"
     },
     "autoload": {
         "psr-0": {
diff --git a/handlers/hipchat.inc b/handlers/hipchat.inc
new file mode 100644
index 0000000..cf3e39a
--- /dev/null
+++ b/handlers/hipchat.inc
@@ -0,0 +1,53 @@
+<?php
+
+/**
+ * @file
+ * Handler include for HipChatHandler.
+ */
+
+use Monolog\Handler\HipChatHandler;
+
+/**
+ * Monolog loader callback; Loads a HipChatHandler handler.
+ *
+ * @return HandlerInterface
+ */
+function monolog_hipchat_handler_loader($options) {
+  return new HipChatHandler($options['token'], $options['room'], $options['contact_name'], $options['notify'], $options['level'], $options['bubble']);
+}
+
+/**
+ * Monolog settings form; Settings for the HipChat handler.
+ */
+function monolog_hipchat_handler_settings(&$form, &$form_state, $profile, array $handler) {
+
+  $form['token'] = array(
+    '#title' => t('HipChat API Token'),
+    '#type' => 'textfield',
+    '#default_value' => $handler['token'],
+    '#description' => t('HipChat API Token.'),
+    '#required' => TRUE,
+  );
+
+  $form['room'] = array(
+    '#title' => t('Room'),
+    '#type' => 'textfield',
+    '#default_value' => $handler['room'],
+    '#description' => t('The room that should be alerted of the message (Id or Name).'),
+    '#required' => TRUE,
+  );
+
+  $form['contact_name'] = array(
+    '#title' => t('Contact Name'),
+    '#type' => 'textfield',
+    '#default_value' => $handler['contact_name'],
+    '#description' => t('Name used in the "from" field.'),
+  );
+
+  $form['notify'] = array(
+    '#title' => t('Trigger a notification in clients.'),
+    '#type' => 'checkbox',
+    '#default_value' => $handler['notify'],
+    '#description' => t('Check this box to notify HipChat clients connected to the room.'),
+  );
+}
diff --git a/monolog.monolog.inc b/monolog.monolog.inc
index fe38d1c..a78d629 100644
--- a/monolog.monolog.inc
+++ b/monolog.monolog.inc
@@ -89,6 +89,18 @@ function monolog_monolog_handler_info() {
     'group' => t('Wrappers / special handlers'),
   );
 
+  $handlers['hipchat'] = array(
+    'label' => t('HipChat Handler'),
+    'description' => t('Logs records to a HipChat chat room using its API.'),
+    'group' => t('Alerts and emails'),
+    'default settings' => array(
+      'token' => '',
+      'room' => '',
+      'contact_name' => variable_get('site_name', 'Drupal'),
+      'notify' => 0,
+    ),
+  );
+
   return $handlers;
 }
 
-- 
1.7.12.4 (Apple Git-37)

