【问题标题】:Print custom schematics logs in angular-cli在 angular-cli 中打印自定义原理图日志
【发布时间】:2018-11-30 13:21:07
【问题描述】:

我正在编写自定义角度升级示意图。

SchematicContext 包含一个可用于调试的记录器对象。

 context.logger.debug('This logger seems to be usefull!');   

运行 angular-cli,我的代码已执行但我看不到日志。

有没有办法激活和配置这个记录器?

【问题讨论】:

    标签: angular angular-cli angular-schematics


    【解决方案1】:

    帮助说要使用--verbose,但它不起作用。

    $ ng add --help
    options:
      --verbose 
        Display additional details about internal operations during execution.
    

    正确的解决方案是将环境变量NG_DEBUG设置为true

    # On macOS:
    $ NG_DEBUG=true ng add @scope/my-schematic
    

    【讨论】:

      【解决方案2】:

      我也无法让 .debug 做任何事情。不过,其他方法也有效:警告、错误、信息等,所以至少这些是有用的。请确保在运行之前运行“yarn build”。

      【讨论】:

        【解决方案3】:

        我不认为调试在默认的日志记录级别是可见的。 正在尝试将日志记录级别更改为 info 或更高。

        【讨论】:

        • 调试不可见的任何原因?我尝试浏览源代码,并没有看到调试方法与信息、警告等有任何区别。
        猜你喜欢
        • 2018-03-07
        • 2018-07-23
        • 2019-06-03
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多