Skip to content
This repository was archived by the owner on Feb 6, 2019. It is now read-only.

Commit b9903f4

Browse files
authored
Merge pull request #3 from leapfrogtechnology/log-max-files
Configure maxFiles option for logging for auto log files removal
2 parents af008a6 + e0bcb87 commit b9903f4

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/config/default.config.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ import path from 'path';
66

77
export default {
88
logging: {
9+
maxFiles: 3,
910
level: 'info',
1011
logDir: 'logs',
1112
jsonFormat: false,
1213
levelColumnWidth: 7,
13-
tsFormat: () => new Date().toISOString(),
14-
dateFormat: 'yyyy-MM-dd'
14+
dateFormat: 'yyyy-MM-dd',
15+
tsFormat: () => new Date().toISOString()
1516
},
1617
db: {
1718
client: 'sqlite3',

src/utils/logger.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ function createLogger(config) {
5656
const {
5757
level,
5858
logDir,
59+
maxFiles,
5960
jsonFormat,
6061
dateFormat
6162
} = config;
@@ -70,10 +71,12 @@ function createLogger(config) {
7071
formatter: opts => customFormatter(opts, config)
7172
}),
7273
new winston.transports.DailyRotateFile({
74+
maxFiles,
7375
align: true,
7476
level: level,
7577
prepend: true,
7678
json: jsonFormat,
79+
zippedArchive: true,
7780
datePattern: dateFormat,
7881
filename: `${logDir}/-log.log`,
7982
formatter: opts => customFormatter(opts, config)

0 commit comments

Comments
 (0)