@alline/core
Advanced tools
Comparing version 2.0.0 to 2.1.0
@@ -0,1 +1,8 @@ | ||
# [2.1.0](https://gitlab.com/alline/core/compare/v2.0.0...v2.1.0) (2020-05-18) | ||
### Features | ||
* add log level ([e0a807b](https://gitlab.com/alline/core/commit/e0a807b2d99db2bf6c16a3e22214f0ceafa0335b)) | ||
# [2.0.0](https://gitlab.com/alline/core/compare/v1.1.0...v2.0.0) (2020-05-18) | ||
@@ -2,0 +9,0 @@ |
@@ -7,2 +7,3 @@ import { Logger } from "winston"; | ||
logger?: Logger; | ||
logLevel?: string; | ||
} | ||
@@ -9,0 +10,0 @@ export interface EpisodeSeriesScrapOption { |
@@ -8,7 +8,10 @@ "use strict"; | ||
const lodash_1 = __importDefault(require("lodash")); | ||
const createDefaultLogger = () => winston_1.createLogger({ | ||
level: process.env.NODE_ENV === "production" ? "info" : "debug", | ||
format: winston_1.format.combine(winston_1.format.colorize({ level: true }), winston_1.format.timestamp(), winston_1.format.printf(({ timestamp, level, message, ...other }) => lodash_1.default.isEmpty(other) | ||
? `${timestamp} [${level}] ${message}` | ||
: `${timestamp} [${level}] ${message} (${JSON.stringify(other)})`)), | ||
const createDefaultLogger = (level) => winston_1.createLogger({ | ||
level, | ||
format: winston_1.format.combine(winston_1.format.colorize({ level: true }), winston_1.format.timestamp(), winston_1.format.printf(({ timestamp, level, label = "default", message, ...other }) => { | ||
const otherStr = lodash_1.default.isEmpty(other) | ||
? "" | ||
: ` (${JSON.stringify(other)})`; | ||
return `${timestamp} [${level}] <${label}> ${message}${otherStr}`; | ||
})), | ||
transports: [new winston_1.transports.Console()] | ||
@@ -18,3 +21,3 @@ }); | ||
constructor(option) { | ||
const { logger = createDefaultLogger() } = option; | ||
const { logLevel = process.env.NODE_ENV === "production" ? "info" : "debug", logger = createDefaultLogger(logLevel) } = option; | ||
this.logger = logger; | ||
@@ -21,0 +24,0 @@ } |
{ | ||
"name": "@alline/core", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"description": "Core for Alline.", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
Sorry, the diff of this file is not supported yet
31360
274