I don't know what cool features of L4P you would be losing if you do this, so someone beat me with a cluestick if needed.

Whenever I want to use a public module but I don't like it's semantics, I write a module to change it to be more friendly. Sometimes this is making a non-OO module behave in an OO fashion, sometimes it is merely changing the API of the object involved, and in a few cases it is turning an OO module into a non OO module. I think this is what you want here.

sub log_it { Log::Log4Perl->logger('section') ->log(shift); }

For instance, if you had a module that exported log_it, you could make sure it calls Log::Log4Perl->init('file.conf') (in BEGIN maybe?) and so make sure that it is always called. Boom, you get your oneliners back.

Plus, you also get shorter call symantics - log_it('my_log_message') is a lot friendlier then Log::Log4Perl->logger('section')->log('my_log_message), but then of course it is the code that is actually run by log_it and so does the same thing with less typing.


In reply to Re^2: Log::Log4perl and singleton design issue by Tuppence
in thread Log::Log4perl and singleton design issue by BUU

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.