Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

logging to iblocks and show notify for admin #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Resident234
Copy link

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'),
),

        )
    ),
    'readonly' => false
),`

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));
`

@Resident234
Copy link
Author

Bitrix is not working on PHP 5.3 , therefore test is failed https://travis-ci.org/bitrix-expert/monolog-adapter/jobs/371573919log-adapter/jobs/371573919

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant