forked from anomalyco/sst
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogger.js
More file actions
43 lines (39 loc) · 1.06 KB
/
Copy pathlogger.js
File metadata and controls
43 lines (39 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
"use strict";
const path = require("path");
const log4js = require("log4js");
log4js.configure({
appenders: {
console: { type: "console", layout: { type: "messagePassThrough" } },
},
categories: {
default: { appenders: ["console"], level: "info" },
},
});
const logger = log4js.getLogger();
const initializeLogger = function (appBuildPath) {
// Initialize logger does 2 things:
// - update 'console' appender's level based on the DEBUG flag
// - create 'file' appender to log to sst-debug.log
log4js.configure({
appenders: {
file: {
type: "fileSync",
filename: path.join(appBuildPath, "sst-debug.log"),
},
console: { type: "console", layout: { type: "messagePassThrough" } },
consoleFilter: {
type: "logLevelFilter",
level: process.env.DEBUG ? "debug" : "info",
appender: "console",
},
},
categories: {
default: { appenders: ["consoleFilter", "file"], level: "trace" },
},
});
};
module.exports = {
logger,
initializeLogger,
getChildLogger: log4js.getLogger,
};