fix(logs): rotate logs on a daily basis instead of incrementing log filename

pull/467/head
sct 3 years ago
parent bd947409e6
commit 395cbb2be6

1
.gitignore vendored

@ -37,6 +37,7 @@ config/settings.json
# logs
config/logs/*.log*
config/logs/*.json
# dist files
dist

@ -53,6 +53,7 @@
"typeorm": "^0.2.29",
"uuid": "^8.3.2",
"winston": "^3.3.3",
"winston-daily-rotate-file": "^4.5.0",
"xml2js": "^0.4.23",
"yamljs": "^0.3.0",
"yup": "^0.32.8"

@ -1,5 +1,17 @@
import * as winston from 'winston';
import 'winston-daily-rotate-file';
import path from 'path';
import fs from 'fs';
// Migrate away from old log
const OLD_LOG_FILE = path.join(__dirname, '../config/logs/overseerr.log');
if (fs.existsSync(OLD_LOG_FILE)) {
const file = fs.lstatSync(OLD_LOG_FILE);
if (!file.isSymbolicLink()) {
fs.unlinkSync(OLD_LOG_FILE);
}
}
const hformat = winston.format.printf(
({ level, label, message, timestamp, ...metadata }) => {
@ -29,10 +41,14 @@ const logger = winston.createLogger({
hformat
),
}),
new winston.transports.File({
filename: path.join(__dirname, '../config/logs/overseerr.log'),
maxsize: 20971520,
maxFiles: 6,
new winston.transports.DailyRotateFile({
filename: path.join(__dirname, '../config/logs/overseerr-%DATE%.log'),
datePattern: 'YYYY-MM-DD',
zippedArchive: true,
maxSize: '20m',
maxFiles: '7d',
createSymlink: true,
symlinkName: 'overseerr.log',
}),
],
});

@ -6114,6 +6114,13 @@ file-entry-cache@^6.0.0:
dependencies:
flat-cache "^3.0.4"
file-stream-rotator@^0.5.7:
version "0.5.7"
resolved "https://registry.yarnpkg.com/file-stream-rotator/-/file-stream-rotator-0.5.7.tgz#868a2e5966f7640a17dd86eda0e4467c089f6286"
integrity sha512-VYb3HZ/GiAGUCrfeakO8Mp54YGswNUHvL7P09WQcXAJNSj3iQ5QraYSp3cIn1MUyw6uzfgN/EFOarCNa4JvUHQ==
dependencies:
moment "^2.11.2"
file-uri-to-path@1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz#553a7b8446ff6f684359c445f1e37a05dacc33dd"
@ -9050,7 +9057,7 @@ moment-timezone@^0.5.31:
dependencies:
moment ">= 2.9.0"
"moment@>= 2.9.0":
"moment@>= 2.9.0", moment@^2.11.2:
version "2.29.1"
resolved "https://registry.yarnpkg.com/moment/-/moment-2.29.1.tgz#b2be769fa31940be9eeea6469c075e35006fa3d3"
integrity sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ==
@ -9828,7 +9835,7 @@ object-copy@^0.1.0:
define-property "^0.2.5"
kind-of "^3.0.3"
object-hash@^2.0.3:
object-hash@^2.0.1, object-hash@^2.0.3:
version "2.0.3"
resolved "https://registry.yarnpkg.com/object-hash/-/object-hash-2.0.3.tgz#d12db044e03cd2ca3d77c0570d87225b02e1e6ea"
integrity sha512-JPKn0GMu+Fa3zt3Bmr66JhokJU5BaNBIh4ZeTlaCBzrBsOeXzwcKKAK1tbLiPKgvwmPXsDvvLHoWh5Bm7ofIYg==
@ -14157,7 +14164,17 @@ widest-line@^3.1.0:
dependencies:
string-width "^4.0.0"
winston-transport@^4.4.0:
winston-daily-rotate-file@^4.5.0:
version "4.5.0"
resolved "https://registry.yarnpkg.com/winston-daily-rotate-file/-/winston-daily-rotate-file-4.5.0.tgz#3914ac57c4bdae1138170bec85af0c2217b253b1"
integrity sha512-/HqeWiU48dzGqcrABRlxYWVMdL6l3uKCtFSJyrqK+E2rLnSFNsgYpvwx15EgTitBLNzH69lQd/+z2ASryV2aqw==
dependencies:
file-stream-rotator "^0.5.7"
object-hash "^2.0.1"
triple-beam "^1.3.0"
winston-transport "^4.2.0"
winston-transport@^4.2.0, winston-transport@^4.4.0:
version "4.4.0"
resolved "https://registry.yarnpkg.com/winston-transport/-/winston-transport-4.4.0.tgz#17af518daa690d5b2ecccaa7acf7b20ca7925e59"
integrity sha512-Lc7/p3GtqtqPBYYtS6KCN3c77/2QCev51DvcJKbkFPQNoj1sinkGwLGFDxkXY9J6p9+EPnYs+D90uwbnaiURTw==

Loading…
Cancel
Save