serge
serge copied to clipboard
Use Log::Log4perl with log levels
The output from "serge sync" is pretty verbose right now. The important parts get lost in the debugging information. Reformatting would help, but Log::Log4perl with log levels would be best. It would allow me to reuse other logging infrastructure at my company.
Obviously not high on the list of priorities, but nice to have. I could submit a pull request for this in the future if/after we roll Serge out.
@iafan Would you consider merging a PR that replaces all prints with Log::Log4perl statements, provided the output of Serge remains exactly the same?
Log::Log4perl-based logging can be handy. Can you share some snippet (or one file converted this way) before the entire PR lands so that we could agree on details?
Specific questions/suggestions I have in mind:
- Use
standard mode
, not the easy one. I want to see calls like$logger->debug('...');
,$logger->warn('etc');
- Define logging based on current package name. Something like
my $log = Log::Log4perl->get_logger(__PACKAGE__);
- Let's agree on how the old
--debug
CLI parameter would work. Can Log4perl just use this as an override default logging level? Can this probably be a shortcut to--loglevel=debug
with the possibility to specify any override level?
All three of your points sound great. I was thinking along the same lines.
I'm not sure when I'll be able to start but it's an enhancement I'm keen to make.
Sure, I'll push a something to a branch after after I finish the a classes and the parameters on the main serge script.
Also: Ideally, Serge should use some reasonable defaults without having a special log config file and without having users to create/alter one. By default, it would use some 'normal' output level which will currently be the same as the current output. Providing --debug
or --loglevel=...
would change the level globally; only when someone wants to debug a particular module, they would need to put a file called e.g. log4perl.conf
next to Serge binary in order to tweak the logging settings. Such config would be listed in .gitignore
. Does that sound reasonable?
And there's one failing test that needs to be fixed upstream before we can integrate Log4perl (though it seems to be a minor one). See https://github.com/mschilli/log4perl/issues/77