diff options
author | Chocobozzz <me@florianbigard.com> | 2021-08-27 14:32:44 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-08-27 15:12:22 +0200 |
commit | 41fb13c330de629df2d23379209e79c7af0f2e9a (patch) | |
tree | 73bc5a90566406b3910f142beae2a879c1e4265d /server/helpers/audit-logger.ts | |
parent | 40e7ed0714f96c01e16de3ac971a4b28116294e1 (diff) | |
download | PeerTube-41fb13c330de629df2d23379209e79c7af0f2e9a.tar.gz PeerTube-41fb13c330de629df2d23379209e79c7af0f2e9a.tar.zst PeerTube-41fb13c330de629df2d23379209e79c7af0f2e9a.zip |
esModuleInterop to true
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 | } |