-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
38 lines (28 loc) · 862 Bytes
/
main.js
File metadata and controls
38 lines (28 loc) · 862 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
36
37
38
'use strict';
const logger = require('./logger.js');
// On application initialization
const application = {};
application.logger = logger(process.stdout)()('app1');
//application.logger = logger('./file.log')(JSON.stringify)('app1');
// In module1
const module1 = {};
module1.logger = application.logger('module1');
// Create functions
const info = module1.logger('info');
const warning = module1.logger('warning');
const error = module1.logger('error');
const debug = module1.logger('debug');
// Usage
info('I have info for you');
warning('Hello there!');
error('World is not found');
debug('Bye!');
/*
const begin = process.hrtime.bigint();
for (let i = 0; i < 1000000; i++) {
info('Write more then 60Mb logs, line: ' + i);
}
const end = process.hrtime.bigint();
const time = (end - begin) / 1000000n;
console.log(`Time: ${time} milliseconds`);
*/