Formatted logs with colors!
This commit is contained in:
parent
4c3c16c24e
commit
7228a703eb
2 changed files with 16 additions and 20 deletions
|
|
@ -14,13 +14,27 @@ module.exports = (logFileName, logLevel) => {
|
||||||
if (!winstonAttached.has(logFileName)) {
|
if (!winstonAttached.has(logFileName)) {
|
||||||
winston.add(new (winston.transports.DailyRotateFile)({
|
winston.add(new (winston.transports.DailyRotateFile)({
|
||||||
filename: logFileName,
|
filename: logFileName,
|
||||||
datePattern: "yyyy-MM-dd.",
|
datePattern: "yyyy-MM-DD",
|
||||||
json: false,
|
json: false,
|
||||||
maxSize: 1000000,
|
maxSize: 1000000,
|
||||||
maxFiles: 7,
|
maxFiles: 7,
|
||||||
level: logLevel
|
level: logLevel
|
||||||
}))
|
}))
|
||||||
winston.add(new winston.transports.Console())
|
winston.add(new winston.transports.Console({
|
||||||
|
format: winston.format.combine(
|
||||||
|
winston.format.colorize(),
|
||||||
|
winston.format.timestamp(),
|
||||||
|
winston.format.align(),
|
||||||
|
winston.format.printf((info) => {
|
||||||
|
const {
|
||||||
|
timestamp, level, message, ...args
|
||||||
|
} = info;
|
||||||
|
|
||||||
|
const ts = timestamp.slice(0, 19).replace('T', ' ');
|
||||||
|
return `${ts} [${level}]: ${message} ${Object.keys(args).length ? JSON.stringify(args, null, 2) : ''}`;
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
}))
|
||||||
winston.level = logLevel
|
winston.level = logLevel
|
||||||
winstonAttached.set(logFileName, winston)
|
winstonAttached.set(logFileName, winston)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
18
yarn.lock
18
yarn.lock
|
|
@ -3591,24 +3591,6 @@ isobject@^3.0.0, isobject@^3.0.1:
|
||||||
resolved "https://registry.yarnpkg.com/isobject/-/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df"
|
resolved "https://registry.yarnpkg.com/isobject/-/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df"
|
||||||
integrity sha1-TkMekrEalzFjaqH5yNHMvP2reN8=
|
integrity sha1-TkMekrEalzFjaqH5yNHMvP2reN8=
|
||||||
|
|
||||||
isomorphic-webcrypto@^2.3.2:
|
|
||||||
version "2.3.4"
|
|
||||||
resolved "https://registry.yarnpkg.com/isomorphic-webcrypto/-/isomorphic-webcrypto-2.3.4.tgz#6d18ee7f795ab2f5e9fd7a5b489abaf9ee2e6af5"
|
|
||||||
integrity sha512-SnOCsm0Vls8jeWP4c26ItHFajzfDlRPcKK4YRUv6jukYGzJwl2tKNwSIAiCh1INdoRttaKhJrLc3HBer1om4HA==
|
|
||||||
dependencies:
|
|
||||||
"@peculiar/webcrypto" "^1.0.22"
|
|
||||||
asmcrypto.js "^0.22.0"
|
|
||||||
b64-lite "^1.3.1"
|
|
||||||
b64u-lite "^1.0.1"
|
|
||||||
msrcrypto "^1.5.6"
|
|
||||||
str2buf "^1.3.0"
|
|
||||||
webcrypto-shim "^0.1.4"
|
|
||||||
optionalDependencies:
|
|
||||||
"@unimodules/core" "*"
|
|
||||||
"@unimodules/react-native-adapter" "*"
|
|
||||||
expo-random "*"
|
|
||||||
react-native-securerandom "^0.1.1"
|
|
||||||
|
|
||||||
isstream@~0.1.2:
|
isstream@~0.1.2:
|
||||||
version "0.1.2"
|
version "0.1.2"
|
||||||
resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a"
|
resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue