-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexample.js
executable file
·52 lines (45 loc) · 1.42 KB
/
example.js
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
/*eslint no-console:0*/
"use strict";
// require index.js because this example file is part of logi
// Use this line instead for normal usage:
// var logi = require('logi');
var logi = require('./index.js');
// Use default settings, logs everything to std streams
var logi1 = logi();
// logs only debug with warning or above levels.
// outputs error and above levels to stderror
// outputs other levels to file
//var logi2 = logi();
var logi2 = logi({threshold:'warning', out:'example2.log'});
// logs to file and roll over.
// outputs error and above levels to stderror
var logi3 = logi({
formatOptions : { omitTimestamp: true },
out : {
file : { path : 'example3.log', size : 100, compress : true }
}
});
var logger1 = logi1.create(module);
var logger2 = logi2.create(module);
var logger3 = logi3.create(module);
console.log('logger1');
logger1.trace('trace %d', 1);
logger1.debug('debug %d', 1);
logger1.info('info %d', 1);
logger1.warn('warn %d', 1);
logger1.error('error %d', 1);
logger1.fatal('hello %s', 'world');
console.log('logger2');
logger2.trace('trace %d', 2);
logger2.debug('debug %d', 2);
logger2.info('info %d', 2);
logger2.warn('warn %d', 2);
logger2.error('error %d', 2);
logger2.fatal('hello %s', 'world');
console.log('logger3');
logger3.debug('debug %d', 3);
logger3.info('info %d', 3);
logger3.notice('notice %d', 3);
logger3.warn('warn %d', 3);
logger3.error('error %d', 3);
logger3.fatal('hello %s', 'world');