This repository has been archived by the owner on Jul 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
example.js
107 lines (77 loc) · 2.61 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
process.env.NODE_LOGGER_SHOWLINES = 1;
process.env.NODE_LOGGER_LEVEL = 'info';
// Granularity checks
var samplemod = require('./lib/examplemod.js');
console.log("Testing granularity for util");
process.env.NODE_LOGGER_LEVEL_lib_examplemod_js = null;
samplemod.foo('util');
process.env.NODE_LOGGER_LEVEL_lib_examplemod_js = 'debug';
samplemod.foo('util');
console.log("Testing granularity for log.js");
process.env.NODE_LOGGER_LEVEL_lib_examplemod_js = null;
samplemod.foo('log');
process.env.NODE_LOGGER_LEVEL_lib_examplemod_js = 'debug';
samplemod.foo('log');
//-- Test data
var obj = {
"name" : "Irakli"
, "lastname" : "Nadareishvili"
, "organization" : "NPR"
, "languages" : ["Node.js", "Java", "Golang", "Python", "Ruby", "TCL"]
, "tvshows" : ["Burn Notice", "Top Gear", "Scrubs"]
}
//------ Winston
console.log('------ USING Winston.js');
var log = require('./lib/metalogger')('winston', 'debug');
log.info('something info');
log.error('something error');
log.debug('something debug');
log.notice('something notice');
log.warning('something warning');
log.alert('something alert');
log.critical('something critical');
log.info(obj);
log.info('some caption', obj);
// Complex syntax:
log.error('caption', 'num: %d, title: %s', 125, "npr");
//------ Log.js
console.log('------ USING LOG.js');
log = require('./lib/metalogger')('log', 'debug');
log.info('something info');
log.error('something error');
log.debug('something debug');
log.notice('something notice');
log.warning('something warning');
log.alert('something alert');
log.critical('something critical');
log.info(obj);
log.info('some caption', obj);
// Complex syntax:
log.error('caption', 'num: %d, title: %s', 125, "npr");
//------ UTIL
console.log('------ USING Util');
log = require('./lib/metalogger')('util', 'debug');
log.info('something info');
log.error('something error');
log.debug('something debug');
log.notice('something notice');
log.warning('something warning');
log.alert('something alert');
log.critical('something critical');
log.info(obj);
log.info('some caption', obj);
// Complex syntax:
log.error('caption', 'num: %d, title: %s', 125, "npr");
//------ UTIL Limitation
log = require('./lib/metalogger')('util', 'alert');
log.info('something info');
log.error('something error');
log.debug('something debug');
log.notice('something notice');
log.warning('something warning');
log.alert('something alert');
log.critical('something critical');
// -- TEST DEFAULTS
log = require('./lib/metalogger')(); //use sefaults or process.env values
log.info("THIS IS TESTING DEFAULTS");
log.warning("WARNING: env process vars are being used!");