logging to iblocks and show notify for admin #8
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi.
I added additional functionality to the monolog-adapter.
Description new functional:
Logging to iblock
http://prntscr.com/jaf5d7
http://prntscr.com/jaf61f
Show log record in admin notify
http://prntscr.com/jaf8ot
Example monolog-adapter settings in .settings.php
`'monolog' => array(
'value' => array(
'formatters' => array(
'StreamHandlerFormatter' => array(
'class' => '\Monolog\Formatter\LineFormatter',
"format" => "%datetime% > %level_name% > %message% %context% %extra%\n",
"dateFormat" => "Y n j, g:i a"
)
),
'handlers' => array(
...........
'BitrixIblockHandler' => array(
'class' => '\Bex\Monolog\Handler\BitrixIblockHandler',
'level' => 'DEBUG',
'iblock_id' => 10, //iblock id in which logs will be recorded
'rotating_count_elements' => 5, //deleting all records from iblock, except the first 'rotating_count_elements' elements
'rotating_count_days' => 2, // deleting elements from iblock, who are older than 'rotating_count_days' days
'notify_to_admin' => true //show notifications for admin
),
),
'loggers' => array(
'app' => array(
'handlers' => array('default'),
),
'debug' => array(
'handlers' => array('debug_log'),
),
'loggerToFile' => array(
'handlers' => array('StreamHandler'),
),
'loggerToFileFormatted' => array(
'handlers' => array('StreamHandlerFormatted'),
),
'loggerToBrowserConsole' => array(
'handlers' => array('BrowserConsoleHandler'),
),
'loggerToRotatingFile' => array(
'handlers' => array('RotatingFileHandler'),
),
'loggerToNativeMailer' => array(
'handlers' => array('NativeMailerHandler'),
),
'loggerToSlackWebhook' => array(
'handlers' => array('SlackWebhookHandler'),
),
'loggerToAll' => array(
'handlers' => array('debug_log', 'StreamHandler', 'StreamHandlerFormatted', 'BrowserConsoleHandler',
'RotatingFileHandler', 'NativeMailerHandler', 'SlackWebhookHandler', 'BitrixIblockHandler'),
),
Example usage:
`use Monolog\Logger;
$loggerToAll = \Monolog\Registry::getInstance('loggerToAll');
$loggerToAll->addWarning('test logs settings all');
$loggerToAll->warning('warning text example settings all');
$loggerToAll->error('error text example settings all');
$loggerToAll->error('error text settings all', array('session' => $_SESSION));
$loggerToAll->info('info text example settings all');
$loggerToAll->info('info text settings all', array('session' => $_SESSION));
$loggerToAll->debug('debug text settings all', array('session' => $_SESSION));
$loggerToAll->info(json_encode(array('session settings all' => $_SESSION)));
$loggerToAll->addInfo('new message settings all', array('session' => $_SESSION));
`