-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsample.js
45 lines (34 loc) · 1.47 KB
/
sample.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
'use strict';
var errorlog = require('./src/errorlog.js');
errorlog.defaultLevel = errorlog.ALL;
console.log('\n... Without any category...\n');
var log1 = errorlog();
log1('I have %d %s, and an object %j', 3, 'apples', { foo: 'bar' });
log1.trace('A trace message');
log1.debug('A debug message');
log1.info('Informational message');
log1.warn('Some sort of warning');
log1.error('Something is wrong...');
log1.fatal('Something is really REALLY wrong...');
log1.log('This is a normal log');
console.log('\n... When a category is specified...\n');
var log2 = errorlog('my category');
log2('I have %d %s and an error', 2, 'mangoes', new Error('Hello, world!'));
log2.trace('Useful when tracing');
log2.debug('A debug message with some extra', {foo: "bar", baz: 12345});
log2.info('Informational message');
log2.warn('Some sort of warning');
log2.error('Something is wrong...');
log2.fatal('Something is really REALLY wrong...');
log2.log('This is a normal log');
console.log('\n... Boring output with defaultColorize = false...\n');
errorlog.defaultColorize = false;
log2('I have %d %s and an error', 2, 'mangoes', new Error('Hello, world!'));
log2.trace('Useful when tracing');
log2.debug('A debug message with some extra', {foo: "bar", baz: 12345});
log2.info('Informational message');
log2.warn('Some sort of warning');
log2.error('Something is wrong...');
log2.fatal('Something is really REALLY wrong...');
log2.log('This is a normal log');
console.log('\n... There you go, all done...\n');