I've three different modules, let's call ModuleA, ModuleB and Common. The Common module contains some helper methods that are required by both ModuleA and ModuleB.
I wanted to have separate log files maintained for each modules, that means, there should be ModuleA.log and ModuleB.log. So in each module I've created a logger object with file handler and with the corresponding file names.
Now the problem is, if I call a method in Common from ModuleA, the log events in Common should be added to ModuleA.log and if I call a method from ModuleB, the log events in Common should be appended to ModuleB.log. For this, currently I'm passing a corresponding logger object as a parameter on the method from Common module which I feel is not a good solution.
Is there any way / patter to handle this scenario?
Commoninto a class to inherit from, I guess you could overrideself.loggerin each of the other two classes.ModuleAorModuleB?