aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/logger.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-03-05 13:26:02 +0100
committerChocobozzz <me@florianbigard.com>2021-03-24 18:18:40 +0100
commit452b3bea082481b84537e55c7cedc1e24860d543 (patch)
treeedd6a3eb988b093abbcde9fd1890b7fa69d8f25f /server/helpers/logger.ts
parentd00717523890dfc90859a27921f20d79d101ae6e (diff)
downloadPeerTube-452b3bea082481b84537e55c7cedc1e24860d543.tar.gz
PeerTube-452b3bea082481b84537e55c7cedc1e24860d543.tar.zst
PeerTube-452b3bea082481b84537e55c7cedc1e24860d543.zip
Introduce tags to the logger
That could help to filter unneeded logs and/or select particular components
Diffstat (limited to 'server/helpers/logger.ts')
-rw-r--r--server/helpers/logger.ts10
1 files changed, 9 insertions, 1 deletions
diff --git a/server/helpers/logger.ts b/server/helpers/logger.ts
index 6917a64d9..a112fd300 100644
--- a/server/helpers/logger.ts
+++ b/server/helpers/logger.ts
@@ -48,7 +48,7 @@ function getLoggerReplacer () {
48} 48}
49 49
50const consoleLoggerFormat = winston.format.printf(info => { 50const consoleLoggerFormat = winston.format.printf(info => {
51 const toOmit = [ 'label', 'timestamp', 'level', 'message', 'sql' ] 51 const toOmit = [ 'label', 'timestamp', 'level', 'message', 'sql', 'tags' ]
52 52
53 const obj = omit(info, ...toOmit) 53 const obj = omit(info, ...toOmit)
54 54
@@ -150,6 +150,13 @@ const bunyanLogger = {
150 error: bunyanLogFactory('error'), 150 error: bunyanLogFactory('error'),
151 fatal: bunyanLogFactory('error') 151 fatal: bunyanLogFactory('error')
152} 152}
153
154function loggerTagsFactory (...defaultTags: string[]) {
155 return (...tags: string[]) => {
156 return { tags: defaultTags.concat(tags) }
157 }
158}
159
153// --------------------------------------------------------------------------- 160// ---------------------------------------------------------------------------
154 161
155export { 162export {
@@ -159,5 +166,6 @@ export {
159 consoleLoggerFormat, 166 consoleLoggerFormat,
160 jsonLoggerFormat, 167 jsonLoggerFormat,
161 logger, 168 logger,
169 loggerTagsFactory,
162 bunyanLogger 170 bunyanLogger
163} 171}