LibreCat / Catmandu

Catmandu - a data processing toolkit
https://librecat.org
176 stars 31 forks source link

Support easy logging via CLI and config file #83

Closed nichtich closed 10 years ago

nichtich commented 10 years ago

While detailed logging is useful for large applications, catmandu should also support easy logging by default, at least if called as command line application. This means:

This could be implemented with dependency on Log::Any::Adapter only. More complex adapters such as Log4Perl could still be used for applications that make use of the Catmandu modules.

phochste commented 10 years ago

Provided the easy logging now with catmandu -d in dev branch (rev: 9bc619b)

For --warn, --verbose, --debug, --trace we probably need an extra dependency on Log::Log4perl or we need to create our own Log::Any::Adapter.

nichtich commented 10 years ago

I bet that Log::Any::Adapter is enough but first think about the intended usage. A configuration file could include something like:

# log to STDERR and File for all categories:
log: - Stderr
     - File: /path/to/file.log
     - adapter: Syslog
       name: foo
       category: /^Catmandu::Importer/

# equivalent to code
use Log::Any::Adapter ('Stderr');
use Log::Any::Adapter ('File', /path/to/file.log);
use Log::Any::Adapter ({ category => qr/^Catmandu::Importer/ }, 'Syslog', name => 'foo');

I have not found out yet, how to set the logging level for different adapters, e.g. errors to STDERR and warnings to a file.

phochste commented 10 years ago

Log::Any needs an Adapter to print debug,error,warning messages. By default you get the File,Stderr en Stdout adapter. But these are quite simplitic and don't know about categories or different levels of warning. What you need is a more simple Log4perl?

nichtich commented 10 years ago

On 17. Mai 2014 11:42:47 MESZ, Patrick Hochstenbach notifications@github.com wrote:

Log::Any needs an Adapter to print debug,error,warning messages. By default you get the File,Stderr en Stdout adapter. But these are quite simplitic and don't know about categories or different levels of warning. What you need is a more simple Log4perl?


Reply to this email directly or view it on GitHub: https://github.com/LibreCat/Catmandu/issues/83#issuecomment-43402576

as far as I understand the documentation Log::Any::Adapter takes care about categories (I am not sure about log levels). What I need most is an easy way to send log messages up to some level to stderr and/or to a file by one or two simple settings on command line and/or the default Catmandu config file.

phochste commented 10 years ago

Created a new branch 'making_sense_of_errors'. Not only are debug,warning messages welcome but also the messages that are now send to the command line tool 'catmandu' are very verbose and very hard to understand. We might have some more work to implement Catmandu::Error

phochste commented 10 years ago

Merge this issue with #16

phochste commented 10 years ago

Fixed in the 'dev' branch see perldoc catmandu and perldoc Catmandu::Fix::logger