During a review of the logging system, it was determined that the system isn't flexible enough to accept alternative logging options for backend operations. This includes future enhancements like Loggly or other third-party logging systems.
The logging system for System Monitor was intended to function much like the current core log system. However, there isn't a logging factory setup for System Monitor. This means that the currently method relies on using a database approach and leaves no room to replace it with an alternative logging backend.
This issue covers:
- Adding and configuring a custom logger factory for System Monitor
- Updating references in the code to use this factory instead of calling the logger class directly.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | system_monitor--3107132--restructure-log-system--3.patch | 20.54 KB | merauluka |
Comments
Comment #2
merauluka commentedI modeled the changes to the logging system in System Monitor on the core logger, except the concept of "Channels" seemed unnecessary in this case. Initial tests work. I ran the following statement from the command line and saw a log appear in the default system monitor database log table.
drush eval "\Drupal::service('system_monitor_logger')->log(5, 'test message through logger', ['monitor_task_name' => 'test_system_monitor_task', 'monitor_type' => 'test', 'description' => 'cli generated description', 'uid' => 1, 'timestamp' => time()]);"Gitlab comparison:
https://git.drupalcode.org/project/system_monitor/compare/8.x-1.x...task...
Comment #3
merauluka commentedUpdated the patch to fix failing tests after the logging system restructure.
Comment #4
robpowellthis is interesting, it looks like this is identical to the logger.factory service in core.services. Can you speak to why it was required to go this far up the layers of abstraction? Side note: service collectors are pretty nifty.
Comment #5
robpowellComment #6
merauluka commented@robpowell The service collector is what does the magic of adding new services automatically when they are tagged with
system_monitor_logger. This is much like what core does withlogger, but I removed the channels aspect.This allows the entire logging system in System Monitor to be completely separate from the core logging system so only items we want to be logged will actually appear in the System Monitor logs.
Comment #9
merauluka commentedMerged into 8 and 9 branches.