From 729e5b16432a3243a2e20ca1ed6263bd4712ce3a Mon Sep 17 00:00:00 2001 From: DIYgod Date: Mon, 19 Nov 2018 11:02:10 +0800 Subject: [PATCH] support setting logger level --- config.js | 1 + docs/en/install/README.md | 2 ++ docs/install/README.md | 2 ++ utils/logger.js | 3 ++- 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/config.js b/config.js index b4c164ae73..e5a235a5ce 100644 --- a/config.js +++ b/config.js @@ -52,4 +52,5 @@ module.exports = { pass: process.env.HTTP_BASIC_AUTH_PASS || 'passw0rd', }, puppeteerWSEndpoint: process.env.PUPPETEER_WS_ENDPOINT, + loggerLevel: process.env.LOGGER_LEVEL || 'info', }; diff --git a/docs/en/install/README.md b/docs/en/install/README.md index c10e26c158..05983756a2 100644 --- a/docs/en/install/README.md +++ b/docs/en/install/README.md @@ -278,6 +278,8 @@ Use environment variables is recommended to avoid conflicts during upgrade. `HTTP_BASIC_AUTH_PASS`: Http basic authentication password, default to `passw0rd`, please change asap +`LOGGER_LEVEL`: specifies the maximum [level](https://github.com/winstonjs/winston#logging-levels) of messages to the console and log file, default to `info` + ### User Authentication Routes in `protected_route.js` will be protected using HTTP Basic Authentication. diff --git a/docs/install/README.md b/docs/install/README.md index 08fea20568..d633b74446 100644 --- a/docs/install/README.md +++ b/docs/install/README.md @@ -284,6 +284,8 @@ gcloud app deploy `HTTP_BASIC_AUTH_PASS`: Http basic authentication 密码, 默认为 `passw0rd`, 请务必修改 +`LOGGER_LEVEL`: 指明输出到 console 和日志文件的日志的最大[等级](https://github.com/winstonjs/winston#logging-levels),默认 `info` + ### 用户认证 `protected_route.js` 内的路由将启用 HTTP Basic Authentication 认证. diff --git a/utils/logger.js b/utils/logger.js index 4805887730..6edda9c33c 100644 --- a/utils/logger.js +++ b/utils/logger.js @@ -1,7 +1,8 @@ const winston = require('winston'); +const config = require('../config'); const logger = winston.createLogger({ - level: 'info', + level: config.loggerLevel, format: winston.format.json(), transports: [ //