log-in-line
v1.0.13
Published
Used to locate the LOG that is printed for a request. When filtering the logs, **LOG:XXX** can be used to locate the LOG of a request.
Downloads
3
Readme
Introduce
Used to locate the LOG that is printed for a request. When filtering the logs, LOG:XXX can be used to locate the LOG of a request.
You can also set the LOG seqno by using the setseqno('abcdefg') function or passing it in when creating a new object, such as new LOG('123456').
Usage
Refer to the following code in the file in use:
const LOG = require('log-in-line');
Add the following code at the beginning of each request:
let log1 = new LOG(); // new an object
Example
const LOG = require('log-in-line');
let log1 = new LOG(); // new an object
log1.LV2('log1 start here!');
log1.setlevel(8); // set the level of the log1
log1.LV1('setlevel 8');
log1.LV5('log1 test1');
log1.ERR('log1 err1');
log1.setlevel(5);
log1.LV1('setlevel 5');
log1.LV5('log1 test2');
log1.ERR('log1 err2');
log1.setlevel(4);
log1.LV1('setlevel 4');
log1.LV5('log1 test3'); // this will not print because of the level(4) is less than 5
log1.ERR('log1 err3');
log1.LV2('log1 end here!');
let log2 = new LOG();
// let log2 = new LOG(123123); // You can specify a running number
log2.LV2('log2 start here!');
log2.setlevel(8);
log2.LV1('setlevel 8');
log2.LV5('log2 test1');
log2.ERR('log2 err1');
log2.setlevel(5);
log2.LV1('setlevel 5');
log2.LV5('log2 test2');
log2.ERR('log2 err2');
log2.setlevel(4);
log2.LV1('setlevel 4');
log2.LV5('log2 test3'); // this will not print because of the level(4) is less than 5
log2.ERR('log2 err3');
log2.setlevel(0);
log2.LV1('setlevel 4');// this will not print because of the level(1) is less than 0
log2.ERR('log2 err4'); // this will print
log2.setlevel(3);
log2.LV2('log2 end here!');
Code execution results:
Use LOG:AIY9K1584758645877 to filter request that print logs using log1
Use LOG:39GB81584758645889 to filter request that print logs using log2
2020-03-21 10:44:05.878|L2|P0-1|LOG:AIY9K1584758645877|example.js|4|log start here!
2020-03-21 10:44:05.887|L1|P0-1|LOG:AIY9K1584758645877|example.js|6|setlevel 8
2020-03-21 10:44:05.888|L5|P0-1|LOG:AIY9K1584758645877|example.js|7|log test1
2020-03-21 10:44:05.888|LE|P0-1|LOG:AIY9K1584758645877|example.js|8|log err1
2020-03-21 10:44:05.888|L1|P0-1|LOG:AIY9K1584758645877|example.js|10|setlevel 5
2020-03-21 10:44:05.888|L5|P0-1|LOG:AIY9K1584758645877|example.js|11|log test2
2020-03-21 10:44:05.889|LE|P0-1|LOG:AIY9K1584758645877|example.js|12|log err2
2020-03-21 10:44:05.889|L1|P0-1|LOG:AIY9K1584758645877|example.js|14|setlevel 4
2020-03-21 10:44:05.889|LE|P0-1|LOG:AIY9K1584758645877|example.js|16|log err3
2020-03-21 10:44:05.889|L2|P0-1|LOG:AIY9K1584758645877|example.js|17|log end here!
2020-03-21 10:44:05.889|L2|P0-1|LOG:39GB81584758645889|example.js|22|log start here!
2020-03-21 10:44:05.889|L1|P0-1|LOG:39GB81584758645889|example.js|24|setlevel 8
2020-03-21 10:44:05.889|L5|P0-1|LOG:39GB81584758645889|example.js|25|log test1
2020-03-21 10:44:05.889|LE|P0-1|LOG:39GB81584758645889|example.js|26|log err1
2020-03-21 10:44:05.889|L1|P0-1|LOG:39GB81584758645889|example.js|28|setlevel 5
2020-03-21 10:44:05.890|L5|P0-1|LOG:39GB81584758645889|example.js|29|log test2
2020-03-21 10:44:05.890|LE|P0-1|LOG:39GB81584758645889|example.js|30|log err2
2020-03-21 10:44:05.890|L1|P0-1|LOG:39GB81584758645889|example.js|32|setlevel 4
2020-03-21 10:44:05.890|LE|P0-1|LOG:39GB81584758645889|example.js|34|log err3
2020-03-21 10:44:05.892|L1|P0-1|LOG:39GB81584758645889|example.js|37|setlevel 4
2020-03-21 10:44:05.892|LE|P0-1|LOG:39GB81584758645889|example.js|38|log err4
2020-03-21 10:44:05.893|L2|P0-1|LOG:39GB81584758645889|example.js|41|log end here!
Versions
version| update
---- | ------
1.0.0 | Release
1.0.7 | Published README.md instructions
Express gratitude
Thank you for your support and I hope it was useful.