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() { get value() {
return { return {
isPackage: envs.isPackage,
connect: { connect: {
port: envs.PORT || 1200, // 监听端口 port: envs.PORT || 1200, // 监听端口
socket: envs.SOCKET || null, // 监听 Unix Socket, null 为禁用 socket: envs.SOCKET || null, // 监听 Unix Socket, null 为禁用

View File

@@ -3,7 +3,14 @@ const config = require('./config');
module.exports = { module.exports = {
init: (conf) => { init: (conf) => {
config.set(conf); config.set(
Object.assign(
{
isPackage: true,
},
conf
)
);
app = require('./app'); app = require('./app');
}, },
request: (path) => 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: // If we're not in production then log to the `console` with the format:
// `${info.level}: ${info.message} JSON.stringify({ ...rest }) ` // `${info.level}: ${info.message} JSON.stringify({ ...rest }) `
// //
logger.add( if (!config.isPackage) {
logger.add(
new winston.transports.Console({ new winston.transports.Console({
format: winston.format.combine(winston.format.colorize(), winston.format.simple()), format: winston.format.combine(winston.format.colorize(), winston.format.simple()),
silent: process.env.NODE_ENV === 'test', silent: process.env.NODE_ENV === 'test',
}) })
); );
}
module.exports = logger; module.exports = logger;