简体   繁体   English

每个类的唯一记录器名称

[英]Unique Logger Name per class

I my Angular application, I use NGXLogger, but the loggername is always the same我是 Angular 应用程序,我使用 NGXLogger,但记录器名称始终相同

[app-app-module.js:2740] [app-app-module.js:2740]

regardless of where the logging takes place.无论日志记录发生在何处。

If would expect the logger name to reflect the module name that has the log.debug('x')如果希望记录器名称反映具有 log.debug('x') 的模块名称

import { NGXLogger } from 'ngx-logger';

constructor (private logger: NGXLogger) 
  {
    _log = logger; 
  }

In order to see a "clear" component name you need to set enableSourceMaps to true in logger config为了看到“清晰”的组件名称,您需要在记录器配置中将enableSourceMaps设置为 true

Be careful, for this to work you need to generate source maps when building请注意,要使其正常工作,您需要在构建时生成源映射

More info in the doc : https://github.com/dbfannin/ngx-logger/blob/master/docs/features.md文档中的更多信息: https ://github.com/dbfannin/ngx-logger/blob/master/docs/features.md

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM