I'm trying to envision the best way of sharing a log file across multiple packages (which happen, also, to be classes). I'm using
Log::Common to handle the log file.
My classes are, say, Foo::Foo, Foo::Bar, and Foo::Baz. There's no "master class" and the Foo::* classes don't inherit from one another.
I can think of a few ways of doing this: I can create a package--say, Foo--which exports a package global $LOG that contains the Log::Common object. The Foo::* classes would need only "use Foo" to gain access to $LOG.
Or, I could create a wrapper class for Log::Common, then instantiate and export a single Foo::Log object to each Foo::* class... though, under the circumstances, it seems redundant.
Is there anything I'm missing? Glossing over? How would you share a single log file across multiple classes?
Thanks!
baphomet.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.