Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • I'm not sure why, but I think the API lacks a certain elegance.

    Personally I'd have done the name'ology differently (although tbh I'm not sure what I'd have used instead).
    • Upon re-reading I think two things I'm not a fan of are the "Any" suffix, and the use of package-named class-level storage.

      What if I want to make an logger for a single object...
      • As far as the package-named class-level storage: the "use Log::Any qw($log)" syntax is just a convenient shorthand that, imho, will be good enough for some modules. If you are uncomfortable with this, you can use the more standard syntax

                my $log = Log::Any->get_logger(category => '...');

        and you would use this to create a lexically scoped logger or a logger contained in an object.

        As far as the "Any" name - I agree, it isn't ideal, but I haven't been able to think of a better
        • I don't mean for $log, I mean for "category => '...'.

          That implies you are keeping inside Log::Any a hash of some sort with the class as the key and an object or log class as the value. That's what I meant by the class-level storage.

          As for ::Any, I notice that Log::Abstract seems to be unused at the moment, if you do a CPAN search for "Abstract" and have a read through some of the modules there, there is a precent for this general type of thing.
          • > As for ::Any, I notice that Log::Abstract seems to be unused at the moment, if you do a
            > CPAN search for "Abstract" and have a read through some of the modules there, there is a
            > precent for this general type of thing.

            Thanks, I like that name much better! "Any" has always seemed rather...indecisive. I'm going to retroactively change this in the journal entry.

            > I don't mean for $log, I mean for "category => '...'.
            >
            > That implies you are keeping inside Log::Any a hash of some sort with the class as the key
            > and an object or log class as the value. That's what I meant by the class-level storage.

            So the question is whether get_logger() automatically memoizes based on the category name, or whether this is the responsibility of the underlying logging package and/or the code registered in set_logger().

            I had leaned towards memoizing, because most logging packages will not handle this for you (log4perl being the exception) and it seems like the expected behavior.

            I wonder what the point would be of creating multiple Log::Abstract loggers with the same category anyway, given that category is the only data upon which the application has to decide what logging package and settings will be used. That is, given two calls

                  my $logger1 = Log::Abstract->get_logger("foo");
                  my $logger2 = Log::Abstract->get_logger("foo");

            wouldn't these pretty much have to return the same logger, unless the routine passed to set_logger() was changing its behavior over time?

            Remember that set_logger can be called more than once in an application to effectively change all existing abstract loggers. So there is little reason for the routine passed to set_logger() to be dynamic across anything other than category.

            I hope that makes sense.

            Jon