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.

Comments

merauluka created an issue. See original summary.

merauluka’s picture

Status: Active » Needs review
StatusFileSize
new15.97 KB

I 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...

merauluka’s picture

StatusFileSize
new20.54 KB

Updated the patch to fix failing tests after the logging system restructure.

robpowell’s picture

this 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.

robpowell’s picture

Status: Needs review » Reviewed & tested by the community
merauluka’s picture

@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 with logger, 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.

  • merauluka committed 902c54e on 8.x-1.x
    Issue #3107132 by merauluka, robpowell: Review and revamp logging system...

  • merauluka committed 902c54e on 9.x-1.x
    Issue #3107132 by merauluka, robpowell: Review and revamp logging system...
merauluka’s picture

Status: Reviewed & tested by the community » Fixed

Merged into 8 and 9 branches.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.