Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^3: Log::Any with die and carp

by perlancar (Hermit)
on Dec 20, 2018 at 10:24 UTC ( [id://1227514]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Log::Any with die and carp
in thread Log::Any with die and carp

You're most welcome.

Log::ger actually has more reverse dependencies on CPAN than Log::Any now.

% lcpan rdeps Log::ger | wc -l
253

% lcpan rdeps Log::Any | wc -l
196

but all those Log::ger reverse deps are mine :-) (haven't found my first vict, er, author yet), while Log::Any is used on CPAN by a whooping 77 different authors:

% lcpan rdeps Log::ger | td select author | sort | uniq
PERLANCAR

% lcpan rdeps Log::Any | td select author | sort | uniq | wc -l
77

I was a long-time Log::Any user before getting annoyed enough to write the replacement, so to tell you in short why I ditched Log::Any: it stopped being lightweight enough to use in some of my modules. Startup time increases by 5-10ms. And if you use Log::Any in your module, suddenly you will also depend on things like IO::File, FindBin, Storable, Sys::Syslog:

% lcpan deps --phase runtime --rel requires Log::Any
+----------------+----------+---------+---------+
| module         | author   | version | is_core |
+----------------+----------+---------+---------+
| B              | SHAY     | 0       | 1       |
| Carp           | XSAWYERX | 0       | 1       |
| Data::Dumper   | XSAWYERX | 0       | 1       |
| Exporter       | TODDR    | 0       | 1       |
| Fcntl          | SHAY     | 0       | 1       |
| File::Basename | SHAY     | 0       | 1       |
| FindBin        | SHAY     | 0       | 1       |
| IO::File       | TODDR    | 0       | 1       |
| Storable       | XSAWYERX | 0       | 1       |
| Sys::Syslog    | SAPER    | 0       | 1       |
| Test::Builder  | EXODIST  | 0       | 1       |
| constant       | RJBS     | 0       | 1       |
| strict         | SHAY     | 0       | 1       |
| warnings       | SHAY     | 0       | 1       |
+----------------+----------+---------+---------+

% lcpan deps --phase runtime --rel requires Log::ger
+--------------+----------+---------+---------+
| module       | author   | version | is_core |
+--------------+----------+---------+---------+
| Data::Dumper | XSAWYERX | 0       | 1       |
| parent       | CORION   | 0       | 1       |
| strict       | SHAY     | 0       | 1       |
| vars         | SHAY     | 0       | 1       |
| warnings     | SHAY     | 0       | 1       |
+--------------+----------+---------+---------+

Granted, all those modules are core, but this shows that Log::Any was not the tiny little module you can just sneak in to your module without much thought anymore, especially if you want your module to also be tiny.

I have made Log::ger to be as light as strict or warnings so the impact of adding use Log::ger; to your module is really minimal. And this is really important to me because I want to be able to use logging pervasively in most (if not all) of my modules when necessary.

Log::ger basically has all the features of Log::Any plus more, with less impact to your module users.

As for Log::Dispatch, it has even much worse startup overhead. It will add ~100ms to your module's startup by loading a whole argument parameter framework (Specio, Params::ValidationCompiler) as well as many extras like Module::Runtime, File::Spec, Storable, Exception::Class, List::Util, so that's not acceptable for some cases. It will pull many non-core dependencies to your module.

Replies are listed 'Best First'.
Re^4: Log::Any with die and carp
by hippo (Bishop) on Dec 20, 2018 at 12:01 UTC
    Log::ger basically has all the features of Log::Any plus more, with less impact to your module users.

    Thanks very much for this comparative analysis. I was entirely ignorant of Log::ger before this and therefore was using Log::Any effectively by default. Your post gives encouragement to try Log::ger as a lightweight replacement.

    One minor off-topic nugget is that sort has a -u option which essentially replaces a vanilla sort | uniq and thereby saves you a process and could make the sort faster (dataset depending, of course).

      You're welcome. Thanks for sort -u. I should know that, but sort | uniq has been in my muscle memory for god knows how many years.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1227514]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (8)
As of 2024-03-28 12:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found