aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/helpers/core-utils.ts2
-rw-r--r--server/helpers/logger.ts60
-rw-r--r--server/initializers/checker.ts2
-rw-r--r--server/initializers/constants.ts3
-rw-r--r--server/models/activitypub/actor-follow.ts2
-rw-r--r--server/tests/api/server/config.ts4
6 files changed, 59 insertions, 14 deletions
diff --git a/server/helpers/core-utils.ts b/server/helpers/core-utils.ts
index 77547c528..65f18d644 100644
--- a/server/helpers/core-utils.ts
+++ b/server/helpers/core-utils.ts
@@ -50,6 +50,8 @@ function root () {
50 50
51// Thanks: https://stackoverflow.com/a/12034334 51// Thanks: https://stackoverflow.com/a/12034334
52function escapeHTML (stringParam) { 52function escapeHTML (stringParam) {
53 if (!stringParam) return ''
54
53 const entityMap = { 55 const entityMap = {
54 '&': '&', 56 '&': '&',
55 '<': '&lt;', 57 '<': '&lt;',
diff --git a/server/helpers/logger.ts b/server/helpers/logger.ts
index 2676133db..6a02f680a 100644
--- a/server/helpers/logger.ts
+++ b/server/helpers/logger.ts
@@ -9,26 +9,57 @@ const label = CONFIG.WEBSERVER.HOSTNAME + ':' + CONFIG.WEBSERVER.PORT
9// Create the directory if it does not exist 9// Create the directory if it does not exist
10mkdirp.sync(CONFIG.STORAGE.LOG_DIR) 10mkdirp.sync(CONFIG.STORAGE.LOG_DIR)
11 11
12const logger = new winston.Logger({ 12// Use object for better performances (~ O(1))
13const excludedKeys = {
14 level: true,
15 message: true,
16 splat: true,
17 timestamp: true,
18 label: true
19}
20function keysExcluder (key, value) {
21 return excludedKeys[key] === true ? undefined : value
22}
23
24const loggerFormat = winston.format.printf((info) => {
25 let additionalInfos = JSON.stringify(info, keysExcluder, 2)
26 if (additionalInfos === '{}') additionalInfos = ''
27
28 return `[${info.label}] ${info.timestamp} ${info.level}: ${info.message} ${additionalInfos}`
29})
30
31const timestampFormatter = winston.format.timestamp({
32 format: 'YYYY-MM-dd HH:mm:ss.SSS'
33})
34const labelFormatter = winston.format.label({
35 label
36})
37
38const logger = new winston.createLogger({
39 level: CONFIG.LOG.LEVEL,
13 transports: [ 40 transports: [
14 new winston.transports.File({ 41 new winston.transports.File({
15 level: 'debug', 42 filename: path.join(CONFIG.STORAGE.LOG_DIR, 'peertube.log'),
16 filename: path.join(CONFIG.STORAGE.LOG_DIR, 'all-logs.log'),
17 handleExceptions: true, 43 handleExceptions: true,
18 json: true,
19 maxsize: 5242880, 44 maxsize: 5242880,
20 maxFiles: 5, 45 maxFiles: 5,
21 colorize: false, 46 format: winston.format.combine(
22 prettyPrint: true 47 timestampFormatter,
48 labelFormatter,
49 winston.format.splat(),
50 winston.format.json()
51 )
23 }), 52 }),
24 new winston.transports.Console({ 53 new winston.transports.Console({
25 level: 'debug',
26 label: label,
27 handleExceptions: true, 54 handleExceptions: true,
28 humanReadableUnhandledException: true, 55 humanReadableUnhandledException: true,
29 json: false, 56 format: winston.format.combine(
30 colorize: true, 57 timestampFormatter,
31 prettyPrint: true 58 winston.format.splat(),
59 labelFormatter,
60 winston.format.colorize(),
61 loggerFormat
62 )
32 }) 63 })
33 ], 64 ],
34 exitOnError: true 65 exitOnError: true
@@ -36,4 +67,9 @@ const logger = new winston.Logger({
36 67
37// --------------------------------------------------------------------------- 68// ---------------------------------------------------------------------------
38 69
39export { logger } 70export {
71 timestampFormatter,
72 labelFormatter,
73 loggerFormat,
74 logger
75}
diff --git a/server/initializers/checker.ts b/server/initializers/checker.ts
index 7cfbc123d..35fab244c 100644
--- a/server/initializers/checker.ts
+++ b/server/initializers/checker.ts
@@ -21,7 +21,7 @@ function checkMissedConfig () {
21 const required = [ 'listen.port', 21 const required = [ 'listen.port',
22 'webserver.https', 'webserver.hostname', 'webserver.port', 22 'webserver.https', 'webserver.hostname', 'webserver.port',
23 'database.hostname', 'database.port', 'database.suffix', 'database.username', 'database.password', 23 'database.hostname', 'database.port', 'database.suffix', 'database.username', 'database.password',
24 'storage.videos', 'storage.logs', 'storage.thumbnails', 'storage.previews', 'storage.torrents', 'storage.cache', 24 'storage.videos', 'storage.logs', 'storage.thumbnails', 'storage.previews', 'storage.torrents', 'storage.cache', 'log.level',
25 'cache.previews.size', 'admin.email', 'signup.enabled', 'signup.limit', 'transcoding.enabled', 'transcoding.threads', 'user.video_quota' 25 'cache.previews.size', 'admin.email', 'signup.enabled', 'signup.limit', 'transcoding.enabled', 'transcoding.threads', 'user.video_quota'
26 ] 26 ]
27 const miss: string[] = [] 27 const miss: string[] = []
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts
index c10213890..cb043251a 100644
--- a/server/initializers/constants.ts
+++ b/server/initializers/constants.ts
@@ -113,6 +113,9 @@ const CONFIG = {
113 URL: '', 113 URL: '',
114 HOST: '' 114 HOST: ''
115 }, 115 },
116 LOG: {
117 LEVEL: config.get<string>('log.level')
118 },
116 ADMIN: { 119 ADMIN: {
117 get EMAIL () { return config.get<string>('admin.email') } 120 get EMAIL () { return config.get<string>('admin.email') }
118 }, 121 },
diff --git a/server/models/activitypub/actor-follow.ts b/server/models/activitypub/actor-follow.ts
index 416496607..a32f5f498 100644
--- a/server/models/activitypub/actor-follow.ts
+++ b/server/models/activitypub/actor-follow.ts
@@ -376,7 +376,7 @@ export class ActorFollowModel extends Model<ActorFollowModel> {
376 [Sequelize.Op.lte]: 0 376 [Sequelize.Op.lte]: 0
377 } 377 }
378 }, 378 },
379 logger: false 379 logging: false
380 } 380 }
381 381
382 return ActorFollowModel.findAll(query) 382 return ActorFollowModel.findAll(query)
diff --git a/server/tests/api/server/config.ts b/server/tests/api/server/config.ts
index 0aa0e2ec1..a1f8212bb 100644
--- a/server/tests/api/server/config.ts
+++ b/server/tests/api/server/config.ts
@@ -112,6 +112,8 @@ describe('Test config', function () {
112 }) 112 })
113 113
114 it('Should have the configuration updated after a restart', async function () { 114 it('Should have the configuration updated after a restart', async function () {
115 this.timeout(10000)
116
115 killallServers([ server ]) 117 killallServers([ server ])
116 118
117 await reRunServer(server) 119 await reRunServer(server)
@@ -134,6 +136,8 @@ describe('Test config', function () {
134 }) 136 })
135 137
136 it('Should remove the custom configuration', async function () { 138 it('Should remove the custom configuration', async function () {
139 this.timeout(10000)
140
137 await deleteCustomConfig(server.url, server.accessToken) 141 await deleteCustomConfig(server.url, server.accessToken)
138 142
139 const res = await getCustomConfig(server.url, server.accessToken) 143 const res = await getCustomConfig(server.url, server.accessToken)