Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

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.

Replies are listed 'Best First'.
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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://887466]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (11)
As of 2018-06-22 16:17 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (124 votes). Check out past polls.