diff options
Diffstat (limited to 'server/helpers/audit-logger.ts')
-rw-r--r-- | server/helpers/audit-logger.ts | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/server/helpers/audit-logger.ts b/server/helpers/audit-logger.ts index 884bd187d..5f2e870e3 100644 --- a/server/helpers/audit-logger.ts +++ b/server/helpers/audit-logger.ts | |||
@@ -1,9 +1,9 @@ | |||
1 | import { diff } from 'deep-object-diff' | 1 | import { diff } from 'deep-object-diff' |
2 | import * as express from 'express' | 2 | import express from 'express' |
3 | import * as flatten from 'flat' | 3 | import flatten from 'flat' |
4 | import { chain } from 'lodash' | 4 | import { chain } from 'lodash' |
5 | import * as path from 'path' | 5 | import { join } from 'path' |
6 | import * as winston from 'winston' | 6 | import { addColors, config, createLogger, format, transports } from 'winston' |
7 | import { AUDIT_LOG_FILENAME } from '@server/initializers/constants' | 7 | import { AUDIT_LOG_FILENAME } from '@server/initializers/constants' |
8 | import { AdminAbuse, User, VideoChannel, VideoDetails, VideoImport } from '../../shared' | 8 | import { AdminAbuse, User, VideoChannel, VideoDetails, VideoImport } from '../../shared' |
9 | import { CustomConfig } from '../../shared/models/server/custom-config.model' | 9 | import { CustomConfig } from '../../shared/models/server/custom-config.model' |
@@ -21,23 +21,23 @@ enum AUDIT_TYPE { | |||
21 | DELETE = 'delete' | 21 | DELETE = 'delete' |
22 | } | 22 | } |
23 | 23 | ||
24 | const colors = winston.config.npm.colors | 24 | const colors = config.npm.colors |
25 | colors.audit = winston.config.npm.colors.info | 25 | colors.audit = config.npm.colors.info |
26 | 26 | ||
27 | winston.addColors(colors) | 27 | addColors(colors) |
28 | 28 | ||
29 | const auditLogger = winston.createLogger({ | 29 | const auditLogger = createLogger({ |
30 | levels: { audit: 0 }, | 30 | levels: { audit: 0 }, |
31 | transports: [ | 31 | transports: [ |
32 | new winston.transports.File({ | 32 | new transports.File({ |
33 | filename: path.join(CONFIG.STORAGE.LOG_DIR, AUDIT_LOG_FILENAME), | 33 | filename: join(CONFIG.STORAGE.LOG_DIR, AUDIT_LOG_FILENAME), |
34 | level: 'audit', | 34 | level: 'audit', |
35 | maxsize: 5242880, | 35 | maxsize: 5242880, |
36 | maxFiles: 5, | 36 | maxFiles: 5, |
37 | format: winston.format.combine( | 37 | format: format.combine( |
38 | winston.format.timestamp(), | 38 | format.timestamp(), |
39 | labelFormatter(), | 39 | labelFormatter(), |
40 | winston.format.splat(), | 40 | format.splat(), |
41 | jsonLoggerFormat | 41 | jsonLoggerFormat |
42 | ) | 42 | ) |
43 | }) | 43 | }) |
@@ -84,9 +84,9 @@ abstract class EntityAuditView { | |||
84 | constructor (private readonly keysToKeep: string[], private readonly prefix: string, private readonly entityInfos: object) { } | 84 | constructor (private readonly keysToKeep: string[], private readonly prefix: string, private readonly entityInfos: object) { } |
85 | 85 | ||
86 | toLogKeys (): object { | 86 | toLogKeys (): object { |
87 | return chain(flatten(this.entityInfos, { delimiter: '-', safe: true })) | 87 | return chain(flatten<object, any>(this.entityInfos, { delimiter: '-', safe: true })) |
88 | .pick(this.keysToKeep) | 88 | .pick(this.keysToKeep) |
89 | .mapKeys((value, key) => `${this.prefix}-${key}`) | 89 | .mapKeys((_value, key) => `${this.prefix}-${key}`) |
90 | .value() | 90 | .value() |
91 | } | 91 | } |
92 | } | 92 | } |