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

central logging mechanism #3230

Closed
wants to merge 7 commits into from
Closed

central logging mechanism #3230

wants to merge 7 commits into from

Conversation

splitbrain
Copy link
Collaborator

@splitbrain splitbrain commented Aug 13, 2020

This introduces a logger mechanism and a new data/log directory. This is a first proof of concept. It's built on top of the new global error handling mechanism of #3203

Things to discuss:

  • should we adopt PSR-3 somehow? if yes, how and should plugins be able to drop-in other psr3 loggers?
  • how to configure which facilities shall be logged?
  • should we implement a log deletion feature?
  • is the log format sensible?
  • should we implement a log viewer admin plugin?
  • should logging trigger events (it should maybe replace the deprecation event)

This introduces a logger mechanism and a new data/log directory. This is
a first proof of concept. It's built on top of the new global error
handling mechanism

Things to discuss:

* should we adopt PSR-3 somehow? if yes, how and should plugins be able
  to drop-in other psr3 loggers?
* how to configure which facilities shall be logged?
* should we implement a log deletion feature?
* is the log format sensible?
* should we implement a log viewer admin plugin?
* should logging trigger events (it should maybe replace the
  deprecation event)
This allows for easy viewing of the available logs.

The log format was sligthly adjusted again for easier parsing.
Log facitlities can now be disabled. By default only debug is disabled.
It might make sense to by default disable deprecated as well?

Debug logging is now independend of the allowdebug method. allowdebug
was often used in two ways: for displaying errors directly to the user
and for logging to the debug log. Now it only controls the former.
@splitbrain
Copy link
Collaborator Author

I worked some more on this. Let's summarize:

  • There \dokuwiki\Logger now which is a singleton (per logging facility) that can be instanced using \dokuwiki\Logger::getInstance($facility)
  • There are three default facilities: error, debug and deprecated but devs can add new facilities as they like (simply pass a string as facility)
  • static convenience methods are available. Eg. \dokuwiki\Logger::error() to directly log to the error log
  • logs are stored in data/log/$facility/$date.log
  • There is a new logviewer plugin bundled which allows to read the logs from the admin menu
  • There is a new config option to disable logging facilities (debug is disabled by default)

Things I'm unsure about:

  • I think different logging facilities are more useful than traditional log levels, thus implementing PSR-3 might not be worth it
  • do we want to encourage plugin authors to use their own facility?
    • if so, the interface of the log viewer is probably not suitable
    • we might need to inverse the log setting, from disabling to explicitly enabling
  • stuff from the original post

Feedback welcome

@splitbrain
Copy link
Collaborator Author

merged into master

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

Successfully merging this pull request may close these issues.

None yet

2 participants