UNPKG

tprompter

Version:
15 lines (14 loc) 504 B
import { Container } from 'typedi'; import { LoggerService } from './index.js'; export function InjectLogger(child) { return function (object, propertyName, index) { const rootLogger = Container.get(LoggerService); const name = typeof child === 'function' ? child.name : child; Container.registerHandler({ object: object, propertyName, index, value: () => (name ? rootLogger.child(name) : rootLogger.root), }); }; }