refactor(logging): move the console line format into src/logging/format.ts
The printf template of config/logger.ts becomes formatLogLine, with the same logic, so it can be unit tested without winston. No behaviour change. Refs libretech/mp#71
This commit is contained in:
+2
-8
@@ -1,16 +1,10 @@
|
||||
import { winston } from "@strapi/logger";
|
||||
import { formatLogLine } from "../src/logging/format";
|
||||
|
||||
export default {
|
||||
transports: [
|
||||
new winston.transports.Console({
|
||||
format: winston.format.combine(
|
||||
winston.format.printf(({ timestamp, level, message, ...rest }) => {
|
||||
let restString = JSON.stringify(rest, undefined, 2);
|
||||
restString = restString === "{}" ? "" : restString;
|
||||
|
||||
return `${timestamp}Z ${level}: ${message} ${restString}`;
|
||||
})
|
||||
)
|
||||
format: winston.format.combine(winston.format.printf(formatLogLine))
|
||||
})
|
||||
]
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user