Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^2: How to "disguise" caller

by menth0l (Monk)
on Feb 10, 2011 at 14:58 UTC ( #887466=note: print w/ replies, xml ) Need Help??


in reply to Re: How to "disguise" caller
in thread How to "disguise" caller

Well, I got several objects of different classes which produce some data which is stored in a container object. When all workers finish, container renders reports and logs them. E.g.

$container->do_FooBarWork(); # Foo::Bar work $container->do_BazWhoWork(); # Baz::Who work $container->createReport(); # renders report for each worker $container->dumpReport(); # dumps all reports to log
Now all reports are logged by Container::dumpReport() method and thus log4perl can't tell which class produced which output. But if container class knew who produced what then it could log it "on behalf" of worker object. In other words i want to "tie" logged result to class that created it.


Comment on Re^2: How to "disguise" caller
Download Code
Re^3: How to "disguise" caller
by moritz (Cardinal) on Feb 10, 2011 at 16:17 UTC

    This might be an easier solution:

    Have a method in each of the worker classes that does the logging regarding its activity, and then call these methods from the container class. That way the reporting also becomes customizable by overriting the reporting method in an inheriting class.

    The container can still do some summary logging, if necessary.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2014-12-22 01:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (110 votes), past polls