-
-
Notifications
You must be signed in to change notification settings - Fork 824
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
community/feature-request#12 - Allow named logging channels #20079
Conversation
Overview ---------------------------------------- Make it easier to route log messages based on their topic (e.g. CiviContribute-related logs vs CiviMail-related logs). Before ------ `Civi::log()` always returns the same instance of `LoggerInterface`, with no clear way to differentiate logs of different business subsystems. After ----- `Civi::log(...)` allows you to optionally request a `LoggerInterface` for a specific theme, e.g. ```php Civi::log('mail')->error('Failed to connect to SMTP server'); Civi::log('ipn')->warning('Transaction rejected by payment processor'); ``` Technical Details ----------------- A few things going on here: * Extensions may start using their own logs (`Civi::log('myext')`) without any special effort. * It is possible to replace or customize specific logs by defining a service `log.CHANNEL_NAME`. * The `psr_log_manager` is a service. An extension like https://lab.civicrm.org/extensions/monolog/ can replace the `psr_log_manager` and use the channel-name in its own way. There is a limitation here in that the list of channels is open-ended. It will be impossible to (eg) detect that a log-user has made a typo in the channel-name. However, this seems like the better trade-off if the alternative is that extensions face races during installation/uninstallation.
(Standard links)
|
@totten this is great in terms of allowing extensions more options & I think is mergeable once I've done some testing. On to shooting the breeze.....
'I want all ipn debug to go to a different file' we can build on this (if we so choose, as a follow up) by
|
|
test fail seems unrelated but will re-run |
test this please |
OK - I tested this locally - if I do
then it does nothing before but after it logs as configured in the extension MOP |
This is great, thanks @totten and eileen (no @ as I read you're taking a break)! |
This builds on the recently added PR civicrm#20079 and changes the default behaviour such that if a channel is used, without any other intervention, it will result in a change to the file name to reflect the channel Channels are a new feature so this won't affect existing sites but I think adding the prefix is a thing that people using different channels might reasonably expect as a helpful default. I kept it such that we ignore anything beyond a narrow range of characters - we could throw an exception rather than silently ignore if we prefer
This builds on the recently added PR civicrm#20079 and changes the default behaviour such that if a channel is used, without any other intervention, it will result in a change to the file name to reflect the channel Channels are a new feature so this won't affect existing sites but I think adding the prefix is a thing that people using different channels might reasonably expect as a helpful default. I kept it such that we ignore anything beyond a narrow range of characters - we could throw an exception rather than silently ignore if we prefer
…channels commit Include in CiviCRM 5.38 PR: civicrm#20079 Overview ---------------------------------------- Make it easier to route log messages based on their topic (e.g. CiviContribute-related logs vs CiviMail-related logs). Before ------ `Civi::log()` always returns the same instance of `LoggerInterface`, with no clear way to differentiate logs of different business subsystems. After ----- `Civi::log(...)` allows you to optionally request a `LoggerInterface` for a specific theme, e.g. ```php Civi::log('mail')->error('Failed to connect to SMTP server'); Civi::log('ipn')->warning('Transaction rejected by payment processor'); ``` Technical Details ----------------- A few things going on here: * Extensions may start using their own logs (`Civi::log('myext')`) without any special effort. * It is possible to replace or customize specific logs by defining a service `log.CHANNEL_NAME`. * The `psr_log_manager` is a service. An extension like https://lab.civicrm.org/extensions/monolog/ can replace the `psr_log_manager` and use the channel-name in its own way. There is a limitation here in that the list of channels is open-ended. It will be impossible to (eg) detect that a log-user has made a typo in the channel-name. However, this seems like the better trade-off if the alternative is that extensions face races during installation/uninstallation.
…channels commit Include in CiviCRM 5.38 PR: civicrm#20079 Overview ---------------------------------------- Make it easier to route log messages based on their topic (e.g. CiviContribute-related logs vs CiviMail-related logs). Before ------ `Civi::log()` always returns the same instance of `LoggerInterface`, with no clear way to differentiate logs of different business subsystems. After ----- `Civi::log(...)` allows you to optionally request a `LoggerInterface` for a specific theme, e.g. ```php Civi::log('mail')->error('Failed to connect to SMTP server'); Civi::log('ipn')->warning('Transaction rejected by payment processor'); ``` Technical Details ----------------- A few things going on here: * Extensions may start using their own logs (`Civi::log('myext')`) without any special effort. * It is possible to replace or customize specific logs by defining a service `log.CHANNEL_NAME`. * The `psr_log_manager` is a service. An extension like https://lab.civicrm.org/extensions/monolog/ can replace the `psr_log_manager` and use the channel-name in its own way. There is a limitation here in that the list of channels is open-ended. It will be impossible to (eg) detect that a log-user has made a typo in the channel-name. However, this seems like the better trade-off if the alternative is that extensions face races during installation/uninstallation.
Overview
Make it easier to route log messages based on their topic (e.g. CiviContribute-related logs vs CiviMail-related logs).
This is a variation+extraction of @eileenmcnaughton's #20068.
Before
Civi::log()
always returns the same instance ofLoggerInterface
, with no clear way to differentiate logs of different business subsystems.After
Civi::log(...)
allows you to optionally request aLoggerInterface
for a specific theme, e.g.Technical Details
A few things going on here:
Civi::log('myext')
) without any special effort.log.CHANNEL_NAME
.psr_log_manager
is a service. An extension like https://lab.civicrm.org/extensions/monolog/ can replace thepsr_log_manager
and use the channel-name in its own way.There is a consideration here in that the list of channels is open-ended. It will be impossible to (eg) detect that a log-user has made a typo in the channel-name. However, this seems like the better trade-off if the alternative is that extensions face races during installation/uninstallation.