-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2fdf912
commit 84f429b
Showing
4 changed files
with
111 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
/** | ||
* @file | ||
* Handler include for ErrorLogHandler. | ||
*/ | ||
|
||
use Monolog\Handler\ErrorLogHandler; | ||
use Monolog\Formatter\JsonFormatter; | ||
|
||
/** | ||
* Monolog loader callback; Loads a ErrorLogHandler handler. | ||
* | ||
* @return HandlerInterface | ||
*/ | ||
function monolog_rdg_error_log_json_handler_loader($options) { | ||
$handler = new ErrorLogHandler(ErrorLogHandler::OPERATING_SYSTEM, $options['level'], $options['bubble']); | ||
$formatter = new JsonFormatter(); | ||
$handler->setFormatter($formatter); | ||
return $handler; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
/** | ||
* @file | ||
* Handler include for StreamHandler. | ||
*/ | ||
|
||
use Monolog\Handler\RotatingFileHandler; | ||
use Monolog\Formatter\JsonFormatter; | ||
|
||
/** | ||
* Monolog loader callback; Loads a RotatingFileHandler handler. | ||
* | ||
* @return HandlerInterface | ||
*/ | ||
function monolog_rdg_rotating_file_json_handler_loader($options) { | ||
$directory = dirname($options['filepath']); | ||
monolog_prepare_log_dir($directory); | ||
$handler = new RotatingFileHandler($options['filepath'], $options['max_files'], $options['level'], $options['bubble']); | ||
$formatter = new JsonFormatter(); | ||
$handler->setFormatter($formatter); | ||
return $handler; | ||
} | ||
|
||
/** | ||
* Monolog settings form; Settings for the RotatingFileHandler handler. | ||
*/ | ||
function monolog_rdg_rotating_file_json_handler_settings(&$form, &$form_state, $profile, array $handler) { | ||
|
||
$form['filepath'] = array( | ||
'#title' => t('Log file path'), | ||
'#type' => 'textfield', | ||
'#default_value' => $handler['filepath'], | ||
'#description' => t('The path or URI that the log file will be written to.'), | ||
); | ||
|
||
$form['max_files'] = array( | ||
'#title' => t('Maximum number of files'), | ||
'#type' => 'textfield', | ||
'#default_value' => $handler['max_files'], | ||
'#description' => t('The maximal amount of files to keep (0 means unlimited).'), | ||
'#size' => 4, | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
name = RDG Monolog | ||
description = Additional Monolog Handlers from Rapid Development Group | ||
package = Rapid Development Group | ||
version = 7.x-1.0 | ||
core = 7.x | ||
|
||
dependencies[] = monolog |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
/** | ||
* @file | ||
* Monolog hook implementations. | ||
*/ | ||
|
||
/** | ||
* Implements hook_monolog_handler_path(). | ||
*/ | ||
function rdg_monolog_monolog_handler_path() { | ||
return 'handlers'; | ||
} | ||
|
||
/** | ||
* Implements hook_monolog_handler_info(). | ||
*/ | ||
function rdg_monolog_monolog_handler_info() { | ||
$handlers = array(); | ||
|
||
$handlers['rdg_rotating_file_json'] = array( | ||
'label' => t('RDG Rotating File Handler - JSON'), | ||
'description' => t('Logs records to a file and creates one logfile per day. It will also delete files older than the "Max Files" settings.'), | ||
'group' => t('Files and syslog'), | ||
'default settings' => array( | ||
'filepath' => 'private://log/drupal.log', | ||
'max_files' => 0, | ||
), | ||
); | ||
|
||
$handlers['rdg_error_log_json'] = array( | ||
'label' => t('RDG ErrorLogHandler Handler - JSON'), | ||
'description' => t('Handler for ErrorLogHandler, logging records to PHP\'s error_log() function.'), | ||
'group' => t('Development'), | ||
'settings callback' => FALSE, | ||
); | ||
|
||
return $handlers; | ||
} |