Thursday, 1 June 2017

Inversify : contextual injection with class name

I am trying to inject loggers into different classes using inversify. The problem is, I want to pass the target class name to the logger to categorize it.

The problem is I can't access the target name.

container.bind<log4js.Logger>(Types.Logger).toDynamicValue(context => {
    let className = context....?; // Finds class name
    return log4js.getLogger(className);
});

Is there any way of doing this other than hardcoding?

Thank you! Antoine



via Antoine Boisier-Michaud

No comments:

Post a Comment