-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogger.js
More file actions
67 lines (54 loc) · 1.3 KB
/
logger.js
File metadata and controls
67 lines (54 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/**
* Squid Core test file, to be remove
*
* Advanced logging with NodeJs
* http://tostring.it/2014/06/23/advanced-logging-with-nodejs/
*
*/
'use strict';
var _ = require('lodash')
, winston = require('winston')
winston.emitErrs = true
var _LOGNAME = '[Desktop::Utils::Logger] '
// Initialize Logger Class
//
// @params {object} config
// @return {object} Logger instance
//
var Logger = function( options )
{
this._LOGGER = false
options = options || false
// no options, no logger
// usefull for test env
if( !options )
return this
// Logger require transports options
if( _.isUndefined( options.transports ) )
throw new Error( _LOGNAME + 'missing transports options' )
//initialize logger
this._LOGGER = new winston.Logger(
{
exitOnError: options.exitOnError || false
, transports: [
new winston.transports[ options.output || 'File' ]( options.transports )
]
})
}
Logger.prototype.getEngineName = function()
{
return 'WINSTON'
}
// Display info level message
//
// @params {mixed} single message or an array of messages
// @return {void}
//
Logger.prototype.print = function( message )
{
// Logger is not setup
if( !this._LOGGER )
return
this._LOGGER.info.apply( this, arguments )
}
module.exports = Logger