serge icon indicating copy to clipboard operation
serge copied to clipboard

Use Log::Log4perl with log levels

Open prat0088 opened this issue 8 years ago • 5 comments

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.

prat0088 avatar Jun 22 '16 08:06 prat0088

@iafan Would you consider merging a PR that replaces all prints with Log::Log4perl statements, provided the output of Serge remains exactly the same?

prat0088 avatar Dec 29 '16 02:12 prat0088

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:

  1. Use standard mode, not the easy one. I want to see calls like $logger->debug('...');, $logger->warn('etc');
  2. Define logging based on current package name. Something like my $log = Log::Log4perl->get_logger(__PACKAGE__);
  3. 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?

iafan avatar Dec 29 '16 05:12 iafan

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.

prat0088 avatar Dec 29 '16 10:12 prat0088

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?

iafan avatar Dec 29 '16 17:12 iafan

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

iafan avatar Dec 29 '16 17:12 iafan