]>
git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - logger.js
281acedb8f3f4152db01c229bb9f54bac947dbed
1 // Thanks http://tostring.it/2014/06/23/advanced-logging-with-nodejs/
4 const mkdirp
= require('mkdirp')
5 const path
= require('path')
6 const winston
= require('winston')
7 winston
.emitErrs
= true
9 const constants
= require('../initializers/constants')
11 const label
= constants
.CONFIG
.WEBSERVER
.HOSTNAME
+ ':' + constants
.CONFIG
.WEBSERVER
.PORT
13 // Create the directory if it does not exist
14 mkdirp
.sync(constants
.CONFIG
.STORAGE
.LOG_DIR
)
16 const logger
= new winston
.Logger({
18 new winston
.transports
.File({
20 filename: path
.join(constants
.CONFIG
.STORAGE
.LOG_DIR
, 'all-logs.log'),
21 handleExceptions: true,
28 new winston
.transports
.Console({
31 handleExceptions: true,
32 humanReadableUnhandledException: true,
42 write: function (message
, encoding
) {
47 // ---------------------------------------------------------------------------
49 module
.exports
= logger