Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^2: Best way to share logging object among multiple objects?

by pileofrogs (Priest)
on Aug 10, 2010 at 23:45 UTC ( [id://854174]=note: print w/replies, xml ) Need Help??


in reply to Re: Best way to share logging object among multiple objects?
in thread Best way to share logging object among multiple objects?

++

If I understand this correctly, I'd want to use a singleton and a role. Making my logger a singleton makes it so each object uses the same Log::Dispatch object. Making it a role makes it so I don't lose my logging capability down a rabbit hole of multiple inheritance in the event my code gets really complex.

Can I even do that?

Does that sound right? Did I totally miss the point?

Thanks!

--Pileofrogs

Replies are listed 'Best First'.
Re^3: Best way to share logging object among multiple objects?
by pemungkah (Priest) on Aug 12, 2010 at 00:43 UTC
    Taking my advice with a chunk or rock salt the size of your head because I (at this late date) have still not learned Moose: I'd say yes, that's probably the simplest. If you use (say) Log::Log4perl, I think that the singleton issue's already taken care of, and all you need at that point is a role that provides the logging features of your choice. Having the role lets you (if you want to) abstract the logging so that you can say "please log this object" to the CanLog role, and the role takes care of the details (e.g., does this object have a detailed_description method I can call, or do I just Data::Dumper it?).

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2024-03-28 23:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found