diff --git a/.idea/php.xml b/.idea/php.xml
new file mode 100644
index 0000000..10b171f
--- /dev/null
+++ b/.idea/php.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/README.md b/README.md
index 490c651..991b048 100644
--- a/README.md
+++ b/README.md
@@ -1,19 +1,21 @@
-Codeigniter-Monolog
+Codeigniter-Monolog - with PaperTrail support
===================
Simple integration of the Monolog Package (https://github.com/Seldaek/monolog) into CodeIgniter by overwriting the CI_Log class.
-Based on https://github.com/pfote/Codeigniter-Monolog, but updating monolog to 1.7.* and supporting file logging more akin to native CodeIgniter logging.
+Based on https://github.com/pfote/Codeigniter-Monolog, but updating monolog to 1.22.* and supporting file logging more akin to native CodeIgniter logging.
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), New Relic (NewRelicHandler) and HipChat (HipChatHandler).
+Supports File (RotatingFileHandler), New Relic (NewRelicHandler), HipChat (HipChatHandler) and Papertrail via SyslogUdpHandler.
+
+Compatible with Codeigniter 3.1.6 and up
Installation
------------
* Install monolog with ```composer require monolog/monolog```
* Make sure your index.php contains ```include_once './vendor/autoload.php';```
-* Copy application/libraries/Log.php and application/config/monolog.php into your CodeIgniter application
+* Copy application/core/MY_Log.php and application/config/monolog.php into your CodeIgniter application
Usage
-----
diff --git a/application/config/monolog.php b/application/config/monolog.php
index 1dae050..f2b74c8 100644
--- a/application/config/monolog.php
+++ b/application/config/monolog.php
@@ -1,10 +1,13 @@
+ * (adjustments) Carlos Umanzor
+ * (original idea and concept) Steve Thomas
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -12,11 +15,16 @@
/* GENERAL OPTIONS */
-$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['handlers'] = array('file', 'new_relic', 'hipchat', 'papertrail'); // valid handlers are file | new_relic | hipchat | papertrail
+$config['handlers'] = array('papertrail'); // Send logs to papertrail only
+$config['channel'] = 'My log'; // channel name which appears on each line of log, use proper naming for control
+$config['threshold'] = '2'; // '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
+/* PAPERTRAIL OPTIONS - Make sure you add the right hostname and port*/
+$config['papertrail_hostname'] = 'logsX.papertrailapp.com';
+$config['papertrail_port'] = '#####';
+
/* FILE HANDLER OPTIONS
* Log to default CI log directory (must be writable ie. chmod 757).
* Filename will be encoded to current system date, ie. YYYY-MM-DD-ci.log
diff --git a/application/libraries/Log.php b/application/core/MY_Log.php
similarity index 90%
rename from application/libraries/Log.php
rename to application/core/MY_Log.php
index db5da65..b034c89 100644
--- a/application/libraries/Log.php
+++ b/application/core/MY_Log.php
@@ -3,21 +3,24 @@
}
/*
- * CodeIgniter Monolog integration
+ * CodeIgniter Monolog integration - Plus Papertrail support
*
- * Version 1.1.1
- * (c) Steve Thomas
+ * (adjustments) Carlos Umanzor
+ * (original idea and concept) Steve Thomas
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
+require_once APPPATH.'vendor/autoload.php';
+
use Monolog\Logger;
use Monolog\ErrorHandler;
use Monolog\Handler\RotatingFileHandler;
use Monolog\Handler\NewRelicHandler;
use Monolog\Handler\HipChatHandler;
use Monolog\Processor\IntrospectionProcessor;
+use Monolog\Handler\SyslogUdpHandler;
/**
* replaces CI's Logger class, use Monolog instead
@@ -25,7 +28,7 @@
* see https://github.com/stevethomas/codeigniter-monolog & https://github.com/Seldaek/monolog
*
*/
-class CI_Log
+class MY_Log
{
// CI log levels
protected $_levels = array(
@@ -72,14 +75,15 @@ public function __construct()
// decide which handler(s) to use
foreach ($this->config['handlers'] as $value) {
switch ($value) {
+ case 'papertrail':
+ $handler = new SyslogUdpHandler($this->config['papertrail_hostname'], $this->config['papertrail_port']);
+ break;
case 'file':
$handler = new RotatingFileHandler($this->config['file_logfile']);
break;
-
case 'new_relic':
$handler = new NewRelicHandler(Logger::ERROR, true, $this->config['new_relic_app_name']);
break;
-
case 'hipchat':
$handler = new HipChatHandler(
$config['hipchat_app_token'],
@@ -88,7 +92,6 @@ public function __construct()
$config['hipchat_app_notify'],
$config['hipchat_app_loglevel']);
break;
-
default:
exit('log handler not supported: ' . $this->config['handler']);
}
@@ -147,4 +150,4 @@ public function write_log(
}
return true;
}
-}
+}
\ No newline at end of file
diff --git a/composer.json b/composer.json
index 70737d1..2c9b3a8 100644
--- a/composer.json
+++ b/composer.json
@@ -1,5 +1,5 @@
{
"require": {
- "monolog/monolog": "~1.17"
+ "monolog/monolog": "1.22.0"
}
}