Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Module Renaming Suggestions

by cees (Curate)
on Jul 01, 2005 at 21:46 UTC ( [id://471825]=note: print w/replies, xml ) Need Help??


in reply to Module Renaming Suggestions

I find it interesting that Log::Message::Simple just made it onto CPAN today. Looks like your not the only one with a Simple log module.

Replies are listed 'Best First'.
Re^2: Module Renaming Suggestions
by TGI (Parson) on Jul 01, 2005 at 22:51 UTC

    There are lots of logging modules. They are either very complex and super featureful or are stripped down and address one problem. I originally wrote my module because I wanted something simple and flexible.

    To get that flexibility I decided to use callbacks to handle formatting. That way if you want simple content wrapping you can have it, or if you want to process complex data structures, you can do that too.

    I've used this module in several projects and it works nicely in both modes. Noting I've looked at seems to be quite as flexible. With other solutions I always wind up having to put a bunch of formatting code all over my programs.

    $loglevel = 2; # should be set by getopt sub loglevel { my $data = shift; return $data->[1] <= $loglevel ? Dumper $data->[0] : ""; } # ... Insert some code here. $log->format(\&loglevel); $log->entry( [$some_ref, 1] ); $log->entry("We always log this!", 'standard' ); # Sticks a time and +date stamp in front of text.


    TGI says moo

      If that is the major feature of your module (and the main difference from other logging modules), how about a name like Log::Formatted?

      In fact, I think your module is more complicated than it needs to be since you definitely want to control formatting, so *::Simple just isn't right. In the odd case that *::Simple would be appropriate, it wouldn't be for a module that requires extra work of setting up callbacks or denoting formats. A truly simple module would do that for you.

      --
      brian d foy <brian@stonehenge.com>

        I am becoming convinced on the simple issue.

        Callbacks aren't required. The simplest usage would be:

        my $log = Log::Simple->('path/to/file.log'); $log->open; foreach my $stuff (@ARGV) { $log->entry("Stuff happened: $stuff"); } $log->exit("Bad stuff happened", 999);

        The standard formatter just sticks a timestamp on each line and prints it. If you don't define a default formatter with format, open, or new, the standard formatter will be used. If you do supply a default formatter, you can access the standard format for an entry by using 'standard' as the format argument.

        I have been thinking about some variant of 'Format' for the name. Because it gets at what this module does that is different from the many other logging modules. The other option I've been considering is something like WithCallbacks. But I haven't on anything that works well.


        TGI says moo

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (2)
As of 2024-04-25 19:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found