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

Simplify logging #1452

5 of 9 tasks
jodal opened this issue Feb 16, 2016 · 3 comments
5 of 9 tasks

Simplify logging #1452

jodal opened this issue Feb 16, 2016 · 3 comments
breaking change C-enhancement


Copy link

@jodal jodal commented Feb 16, 2016

Following up on @jcass77 and my discussion about logging a few weeks ago...

Current situation

Today, there are four logging output modes that I can think of:

  1. Log to stdout (run mopidy),
  2. Log to stdout and then into some logging service (start mopidy with systemd, and the stdout output ends up in the systemd journal),
  3. Log to a debug log (run mopidy --save-debug-log), typically ./mopidy.log,
  4. Log to anything defined in a logging config, as pointed to by the config value logging/config_file, typically /var/log/mopidy/mopidy.log.

The loglevels config section affects logging in cases 1 and 2, but not 3 or 4.

There are six global verbosity levels:

  • -q: warnings from mopidy, errors from everything else
  • default: info from mopidy, errors from everything else
  • -v: debug from mopidy, warnings from everything else
  • -vv: debug from mopidy, info from everything else
  • -vvv: debug from everything
  • -vvvv: no filter at all, even custom levels lower than debug will be included

The global verbosity level cannot be controlled from the config file.

We have two configs for logging format:

  • logging/console_format is used when no filter (verbosity level and loglevels/*) is at debug level (in other words: -q and default verbosity level, when no loglevels/* config is set to debug level). This is a conventional log format, just containing log level and message.
  • logging/debug_format is used when any filter (verbosity level and loglevels/*) is at debug level. This use multiple lines per log statement for better readability, and includes log level, time, PID, thread name, logger name, and message.

In addition the Debian package configures a log format for /var/log/mopidy/mopidy.log which has the same elements as logging/debug_format, just without newlines and with two items reordered.


Log output:

  • Remove the --save-debug-log command line option and the logging/debug_file config value. Replace it with mopidy -vvvv | tee mopidy.log in the troubleshooting docs.
  • Stop shipping a logging.conf with the Debian and Arch packages, as modern systems now run systemd and journald, so we shouldn't need to take care of file logging ourselves.
  • Add examples to troubleshooting docs on how to access your Mopidy log using sudo journalctl -u mopidy, etc.

loglevels config section: Output mode 3 and 4 from the current situation is gone, so this now applies to all output modes.

Verbosity levels:

  • Add a logging/verbosity config which is a number between -1 and 4 (-q and -vvvv), defaulting to 0, for controlling default logging verbosity level. Any use of -q or -v will override this, like any command line options always do.

Log formats:

  • Remove logging/console_format.
  • Rename logging/debug_format to logging/format, keeping the current default log format.
  • Make distribution packages override logging/format in /etc/mopidy/mopidy.conf to not include timestamp and PID, as that is redundant in the systemd journal.
  • Test how journalctl behaves when getting multiline log messages. We have multiline log messages both because of the log format and because some log messages contains newlines, like MPD protocol messages.
  • Make distribution packages set logging/color to false, as I've seen the systemd journal print the color codes, so it becomes plain noise.

End result

  • All logging goes to stdout, any redirection to syslog or file must be handled outside Mopidy.
  • We still have six global verbosity levels, but they can be set from config.
  • We no longer have a variance in logging format. A single config controls it all.
  • The loglevels/* config section affects all log output, making debugging something without knowing the internals of mopidy.internal.logging possible.
@jodal jodal added C-enhancement breaking change labels Feb 16, 2016
@jodal jodal added this to the v3.0 - Python 2+3 support milestone Feb 16, 2016
@jodal jodal changed the title Simplify logging infrastructure Simplify logging Feb 16, 2016
Copy link

@adamcik adamcik commented Feb 16, 2016

For the color part we could also detect if we have a tty or something else.

Rest of this looks sane though.

Copy link

@adamcik adamcik commented Feb 16, 2016

Oh, and we should make sure that setting just say -o loglevels/ works without having to change the verbosity level of other things. Don't remember the current state of this.

Copy link
Member Author

@jodal jodal commented Dec 26, 2019

All of the above suggestions have been applied to the Debian package in version 3.0.1-1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
breaking change C-enhancement
None yet

No branches or pull requests

2 participants