-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.js
More file actions
33 lines (29 loc) · 902 Bytes
/
example.js
File metadata and controls
33 lines (29 loc) · 902 Bytes
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
const setupLogger = require("dera-logger");
// levels
// error: 0,
// warn: 1,
// info: 2,
// http: 3,
// verbose: 4,
// debug: 5,
// silly: 6
const options = {
logDirectory: "logs",
timestampFormat: "HH:mm:ss",
fileDatePattern: "YYYY-MM-DD",
zippedArchive: false,
maxLogFileSize: null,
maxFiles: "14d",
addConsoleInNonProduction: true,
transports: [
{ filename: "combined", level: "silly", source: "backend" },
{ filename: "error", level: "warn", source: "backend" },
{ filename: "combined", level: "silly", source: "frontend" },
{ filename: "error", level: "warn", source: "frontend" },
{ filename: "combined", level: "silly" }, // source is optional
{ filename: "error", level: "warn" },
],
};
const logger = setupLogger(options);
logger.error("An error occurred", "backend");
logger.info("A new request has been received");