Rabu, 17 Maret 2010

Log::Any::App (2)

Following up on my previous post, I've just uploaded Log::Any::App to CPAN.

Do you write or use modules that use Log::Any? Or, do you want to use Log::Any conveniently in an application? Now you can just do this:

% perl -MLog::Any::App -MOtherModuleThatUsesLogAny -e ...

and the logs will be displayed to screen. The default level is WARN, but if you want to debug things:

% DEBUG=1 perl -MLog::Any::App ...

or if you want to quiet things down:

% LOGLEVEL=error perl -MLog::Any::App ...

If you put 'use Log::Any::App' in your script, when run it will by default log to file too (~/prog.log or /var/log/prog.log). It can even automatically log to syslog.

Zero-conf. No more long incantation.

Please tell me what you think.

2 komentar:

  1. Just tried Log::Any::App,
    cpan -i Log::Any::App

    used the module inside the script, ran the script, got error messages, and looks i must install Log::Any,
    cpan -i Log::Any
    Ran the script again, and everything looks good.

    I thought when i did cpan -i for Log::Any::App, then cpan will handle dependencies.

    I'm just curious, so i installed Log::Any::App on friend's box
    cpan -i Log::Any::App
    ran the script, then the module throwed error messages
    ERROR: can't load appenderclass 'Log::Dispatch::FileRotate'


    cpan -i Log::Dispatch::FileRotate solved the issue

    BalasHapus
  2. @zak: Strange. Log::Any::App does list Log::Any, Log::Dispatch::FileRotate, and a few other dists as its dependencies. Maybe it's your CPAN client's configuration that does not automatically download + install dependencies? Or, maybe the dependencies failed to be installed?

    Btw, just tried this on a plain Debian Lenny. Everything seems to be OK.

    # apt-get update
    # apt-get install build-essential libperl-dev
    ...
    # cpan
    cpan> notest install Log::Any::App
    ...
    # perl -MLog::Any::App='$log' -e'$log->warn("Hello, world!")'
    [4] hello, world!
    #

    BalasHapus

Catatan: Hanya anggota dari blog ini yang dapat mengirim komentar.