#20 Add a configurable syslog handler.
Merged by bowlofeggs. Opened by bowlofeggs.
bowlofeggs/fegistry 4  into  master

Download 20.patch

This commit adds a syslog handler to fegistry. It also adds a
simple YAML configuration system to fegistry, and uses it to allow
the user to configure the syslog handler's log level.

Signed-off-by: Randy Barlow randy@electronsweatshop.com

FYI this can be used to call Python functions if the YAML is malicious. Obviously if someone has written malicious YAML to /etc/fegistry/ you're in trouble anyway, but the path is configurable via an environment variable...

yaml.safe_load recognizes only standard YAML tags and cannot construct an arbitrary Python object so you might want to use it here.

I'm sure it is a super class, but is it a superclass?

So this happens with the default Flask logging configuration, right?

The docs say that it logs to stderr if the application is in debug mode. Does it log to anything if the application isn't in debug mode?

Out of curiosity, why syslog? I've been logging to stdout/err and letting systemd handle logging that.

Yeah at this point we haven't set up our own logger yet. I could set up a logger at the INFO level before loading the config, and then change the logger's log level after we've read the config and know what the user wanted it set to if you think that would be better. However, if a user is having trouble getting it to load a config file it might make sense to load it in debug mode anyway. What do you think?

There are a few reasons I think logging to syslog directly is still better:

  1. Logging to stdout/err only allows you two log levels, but logging to syslog gives us quite a few (debug, info, warning, error), which lets users filter out fairly granularly after the fact if they want. Of course, this also makes configuring the log level a little moot, but the setting will still control how much data is sent to syslog so I think it's still a useful setting,
  2. I don't want to assume all users will be using systemd, even though I love systemd ☺
  3. Sending logs to syslog can also be more flexible for using centralized log collectors, or rsyslog (for users who prefer alternate loggers).
  4. I'm not totally sure that all web servers would pass stdout/err on to their parent process (maybe they do?)

rebased

@jcline I've fixed the copy/paste docblock error (oops) and I used yaml.safe_load() (good catch, I didn't know about that!) I also left some responses to some of your other comments.

How does this look now?

Looks good to me :thumbsup:

Pull-Request has been merged by bowlofeggs

Metadata