diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2016-01-30 17:05:22 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2016-01-30 17:05:22 +0100 |
commit | cda021079ff455cc0fd0eb95a5395fa808ab63d1 (patch) | |
tree | 056716de7460462b74b861051a5e9da6e2633fce /helpers/logger.js | |
parent | 86435b9baedfe300a28ea4545511c1b50d4119f6 (diff) | |
download | PeerTube-cda021079ff455cc0fd0eb95a5395fa808ab63d1.tar.gz PeerTube-cda021079ff455cc0fd0eb95a5395fa808ab63d1.tar.zst PeerTube-cda021079ff455cc0fd0eb95a5395fa808ab63d1.zip |
New directory organization
Diffstat (limited to 'helpers/logger.js')
-rw-r--r-- | helpers/logger.js | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/helpers/logger.js b/helpers/logger.js new file mode 100644 index 000000000..850af10cb --- /dev/null +++ b/helpers/logger.js | |||
@@ -0,0 +1,40 @@ | |||
1 | ;(function () { | ||
2 | // Thanks http://tostring.it/2014/06/23/advanced-logging-with-nodejs/ | ||
3 | 'use strict' | ||
4 | |||
5 | var config = require('config') | ||
6 | var winston = require('winston') | ||
7 | |||
8 | var logDir = __dirname + '/../' + config.get('storage.logs') | ||
9 | |||
10 | winston.emitErrs = true | ||
11 | |||
12 | var logger = new winston.Logger({ | ||
13 | transports: [ | ||
14 | new winston.transports.File({ | ||
15 | level: 'debug', | ||
16 | filename: logDir + '/all-logs.log', | ||
17 | handleExceptions: true, | ||
18 | json: true, | ||
19 | maxsize: 5242880, | ||
20 | maxFiles: 5, | ||
21 | colorize: false | ||
22 | }), | ||
23 | new winston.transports.Console({ | ||
24 | level: 'debug', | ||
25 | handleExceptions: true, | ||
26 | humanReadableUnhandledException: true, | ||
27 | json: false, | ||
28 | colorize: true | ||
29 | }) | ||
30 | ], | ||
31 | exitOnError: true | ||
32 | }) | ||
33 | |||
34 | module.exports = logger | ||
35 | module.exports.stream = { | ||
36 | write: function (message, encoding) { | ||
37 | logger.info(message) | ||
38 | } | ||
39 | } | ||
40 | })() | ||