-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathexamples.js
More file actions
35 lines (28 loc) · 831 Bytes
/
examples.js
File metadata and controls
35 lines (28 loc) · 831 Bytes
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
var logger = require('./logger.js').getLogger('EngineSubSystem');
// Simple logging:
function init() {
logger.debug('Calibrating hyperplan gyroscope...');
}
// Using arguments in a message using util.format() syntax
function runChecks() {
var i = 12;
var total = 287;
logger.info('Running system checks %d out of %d', i, total);
}
// Logging in an anonymous method
warn = function() {
var error = new Error('null');
logger.debug('The system is about to crash');
logger.warn('Polarization failure, switching to backup generator', error);
}
// Passing an error to the logger
function shutdown() {
var error = new Error('Divided by e^(pi * i) + 1');
logger.error('Catastrophic failure!', error);
}
init();
// Change the log level
logger.level = 'INFO';
runChecks();
warn.call();
shutdown();