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

Closed
jodal opened this issue Feb 16, 2016 · 3 comments
Closed

Simplify logging #1452

jodal opened this issue Feb 16, 2016 · 3 comments
Assignees
Milestone

Comments

@jodal
Copy link
Member

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

Proposal

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 changed the title Simplify logging infrastructure Simplify logging Feb 16, 2016
@adamcik

This comment has been minimized.

Copy link
Member

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

@adamcik

This comment has been minimized.

Copy link
Member

@adamcik adamcik commented Feb 16, 2016

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

@jodal jodal mentioned this issue Jun 22, 2019
18 of 19 tasks complete
@jodal jodal self-assigned this Aug 3, 2019
@jodal jodal mentioned this issue Aug 3, 2019
@jodal jodal closed this in 77a1381 Aug 5, 2019
@jodal

This comment has been minimized.

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
Projects
None yet
2 participants
You can’t perform that action at this time.