feat: disable console log for pkg

This commit is contained in:
DIYgod
2019-09-18 17:57:05 +08:00
parent 4445443946
commit 4ae28e48b5
3 changed files with 17 additions and 7 deletions

View File

@@ -27,6 +27,7 @@ module.exports = {
},
get value() {
return {
isPackage: envs.isPackage,
connect: {
port: envs.PORT || 1200, // 监听端口
socket: envs.SOCKET || null, // 监听 Unix Socket, null 为禁用

View File

@@ -3,7 +3,14 @@ const config = require('./config');
module.exports = {
init: (conf) => {
config.set(conf);
config.set(
Object.assign(
{
isPackage: true,
},
conf
)
);
app = require('./app');
},
request: (path) =>

View File

@@ -21,11 +21,13 @@ const logger = winston.createLogger({
// If we're not in production then log to the `console` with the format:
// `${info.level}: ${info.message} JSON.stringify({ ...rest }) `
//
if (!config.isPackage) {
logger.add(
new winston.transports.Console({
format: winston.format.combine(winston.format.colorize(), winston.format.simple()),
silent: process.env.NODE_ENV === 'test',
})
);
}
module.exports = logger;