aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/logger.js
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-03-07 11:33:59 +0100
committerChocobozzz <florian.bigard@gmail.com>2016-03-07 11:33:59 +0100
commitb9a3e09ad5a7673f64556d1dba122ed4c4fac980 (patch)
tree66d4928b82af19a2372a2505822233884f3fd471 /server/helpers/logger.js
parentb2ff5e3e686eb552c5ccd64ce67b0455972ceef0 (diff)
downloadPeerTube-b9a3e09ad5a7673f64556d1dba122ed4c4fac980.tar.gz
PeerTube-b9a3e09ad5a7673f64556d1dba122ed4c4fac980.tar.zst
PeerTube-b9a3e09ad5a7673f64556d1dba122ed4c4fac980.zip
Prepare folders structure for angular app
Diffstat (limited to 'server/helpers/logger.js')
-rw-r--r--server/helpers/logger.js40
1 files changed, 40 insertions, 0 deletions
diff --git a/server/helpers/logger.js b/server/helpers/logger.js
new file mode 100644
index 000000000..67f69a875
--- /dev/null
+++ b/server/helpers/logger.js
@@ -0,0 +1,40 @@
1// Thanks http://tostring.it/2014/06/23/advanced-logging-with-nodejs/
2'use strict'
3
4var config = require('config')
5var path = require('path')
6var winston = require('winston')
7winston.emitErrs = true
8
9var logDir = path.join(__dirname, '..', config.get('storage.logs'))
10var logger = new winston.Logger({
11 transports: [
12 new winston.transports.File({
13 level: 'debug',
14 filename: path.join(logDir, 'all-logs.log'),
15 handleExceptions: true,
16 json: true,
17 maxsize: 5242880,
18 maxFiles: 5,
19 colorize: false
20 }),
21 new winston.transports.Console({
22 level: 'debug',
23 handleExceptions: true,
24 humanReadableUnhandledException: true,
25 json: false,
26 colorize: true
27 })
28 ],
29 exitOnError: true
30})
31
32logger.stream = {
33 write: function (message, encoding) {
34 logger.info(message)
35 }
36}
37
38// ---------------------------------------------------------------------------
39
40module.exports = logger