我正在开发一个 Node.js 应用程序,使用babel-cli作为 ES6 转译器,我使用Winston 3.0作为我的日志记录服务。
我希望来自 winston 记录器的整个消息输出以彩色显示,不仅是标签和消息,还有时间戳。我知道,在 Winston 2.x 中,这在某些方面是可能的(虽然不知道如何)。
我已经尝试过不同的 NPM 包,例如winston color和winston-console-formatter,但它们似乎不起作用。
我已经定义了我的记录器如下:
import winston from 'winston'
let alignColorsAndTime = winston.format.combine(
winston.format.colorize({
all:true
}),
winston.format.label({
label:'[LOGGER]'
}),
winston.format.timestamp({
format:"YY-MM-DD HH:MM:SS"
}),
winston.format.printf(
info => ` ${info.label} ${info.timestamp} ${info.level} : ${info.message}`
)
);
export const logger = winston.createLogger({
level: "debug",
transports: [
new (winston.transports.Console)({
format: alignColorsAndTime
})
],
});
Run Code Online (Sandbox Code Playgroud)
我express-handlebars在我的项目中使用并有以下问题:
问题
我希望能够<script>从视图内部调用的局部视图向我的整体视图头部添加其他此类标签。
例子:
风景
{{#layout/master}}
{{#*inline "head-block"}}
<script src="some/source/of/script">
{{/inline}}
...
{{>myPartial}}
{{/layout/master}}
Run Code Online (Sandbox Code Playgroud)
该视图正在扩展我用作布局的另一个部分(布局/主)。它通过内联部分符号将其内容添加到那个 head 块中,这很好用
部分“我的部分
<script src="another/script/src/bla"></script>
<h1> HELLO </h1>
Run Code Online (Sandbox Code Playgroud)
现在,我希望将其中的特定脚本标记添加到我的视图头块中。我尝试通过@root符号进行,但只能在那里引用上下文。不改变任何东西。
我知道我可以使用 jquery 或类似的方法来通过引用文档头等来添加内容。但我想知道这是否可以通过 Handlebars 实现。
我确实怀疑它以任何方式存在。但是,如果您有任何想法或建议,请务必按照我的方式发送!非常感谢!!!