import { IContext } from "../../framework/api/IContext" ; import { IExtension } from "../../framework/api/IExtension" ; import { ILogger } from "../../framework/api/ILogger" ; /**
 * Allows you to @inject unique loggers into your objects.
 *
 * There are two ways to inject the logger on the constructor of your class:
 *
 * * Using the literal string "ILogger":
 *
 * <code>
 *     constructor( @inject("ILogger") logger: ILogger ) { ... }
 * </code>
 *
 * * Using the ILogger Symbol:
 *
 * <code>
 *     constructor( @inject(ILogger) logger: ILogger ) { ... }
 * </code>
 */ export class InjectableLoggerExtension implements IExtension { inheritDoc public extend ( context ) { context . injector . bind < ILogger > ( "ILogger" ) . toDynamicValue ( ( ) => { return context . getLogger ( null ) ; } ) . onActivation ( ( ctx , logger ) => { logger . source = ctx . plan . rootRequest . serviceIdentifier ; return logger ; } ) ; context . injector . bind < ILogger > ( ILogger ) . toDynamicValue ( ( ) => { return context . getLogger ( null ) ; } ) . onActivation ( ( ctx , logger ) => { logger . source = ctx . plan . rootRequest . serviceIdentifier ; return logger ; } ) ; } }