aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/audit-logger.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-08-27 14:32:44 +0200
committerChocobozzz <me@florianbigard.com>2021-08-27 15:12:22 +0200
commit41fb13c330de629df2d23379209e79c7af0f2e9a (patch)
tree73bc5a90566406b3910f142beae2a879c1e4265d /server/helpers/audit-logger.ts
parent40e7ed0714f96c01e16de3ac971a4b28116294e1 (diff)
downloadPeerTube-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.ts30
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 @@
1import { diff } from 'deep-object-diff' 1import { diff } from 'deep-object-diff'
2import * as express from 'express' 2import express from 'express'
3import * as flatten from 'flat' 3import flatten from 'flat'
4import { chain } from 'lodash' 4import { chain } from 'lodash'
5import * as path from 'path' 5import { join } from 'path'
6import * as winston from 'winston' 6import { addColors, config, createLogger, format, transports } from 'winston'
7import { AUDIT_LOG_FILENAME } from '@server/initializers/constants' 7import { AUDIT_LOG_FILENAME } from '@server/initializers/constants'
8import { AdminAbuse, User, VideoChannel, VideoDetails, VideoImport } from '../../shared' 8import { AdminAbuse, User, VideoChannel, VideoDetails, VideoImport } from '../../shared'
9import { CustomConfig } from '../../shared/models/server/custom-config.model' 9import { 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
24const colors = winston.config.npm.colors 24const colors = config.npm.colors
25colors.audit = winston.config.npm.colors.info 25colors.audit = config.npm.colors.info
26 26
27winston.addColors(colors) 27addColors(colors)
28 28
29const auditLogger = winston.createLogger({ 29const 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}