in reply to How to "disguise" caller

I need it to log messages in log4perl as if they were logged from totally different module...

I don't know your larger background, and I can't answer your question, but want to point out that when parts of your software is lying to other parts of the software, that's a strong indication that there's a larger problem in the design of your code.

Maybe logging is abused for something it was never meant to? Or maybe it's really an XY Problem?

Also, would you care to provide more background information about why this is necessary? I'm really curious.

Replies are listed 'Best First'.
Re^2: How to "disguise" caller
by menth0l (Monk) on Feb 10, 2011 at 14:58 UTC
    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.

      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.

Re^2: How to "disguise" caller
by Voronich (Hermit) on Feb 10, 2011 at 14:45 UTC

    I'd bet lunch he's mocking up output to feed a test without executing something undesirable, or something similar.

    In which case it would be... less bad.

    http://www.mpwilson.com/#pm