File tree Expand file tree Collapse file tree 3 files changed +36
-56
lines changed Expand file tree Collapse file tree 3 files changed +36
-56
lines changed Original file line number Diff line number Diff line change 22
33const metalog = require ( '..' ) ;
44
5- ( async ( ) => {
6- const logger = await metalog . openLog ( {
7- path : './log' ,
8- workerId : 7 ,
9- writeInterval : 3000 ,
10- writeBuffer : 64 * 1024 ,
11- keepDays : 5 ,
12- home : process . cwd ( ) ,
13- json : true ,
14- } ) ;
15-
5+ const testConsoleMethods = async ( logger ) => {
166 const { console } = logger ;
177 console . clear ( ) ;
188 console . assert ( true , 'Assert message: passed' ) ;
@@ -37,6 +27,35 @@ const metalog = require('..');
3727 console . timeLog ( 'time-label' , 'Test log message for console.timeLog' ) ;
3828 console . trace ( 'Test log message for console.trace' , 'arg2' ) ;
3929 console . warn ( 'Test log message for console.warn' , 'arg2' ) ;
30+ } ;
31+
32+ const run = async ( ) => {
33+ console . log ( 'Testing regular logging mode...' ) ;
34+ const logger = await metalog . openLog ( {
35+ path : './log' ,
36+ workerId : 7 ,
37+ writeInterval : 3000 ,
38+ writeBuffer : 64 * 1024 ,
39+ keepDays : 5 ,
40+ home : process . cwd ( ) ,
41+ } ) ;
42+
43+ await testConsoleMethods ( logger ) ;
44+ await logger . close ( ) ;
45+
46+ console . log ( '\nTesting JSON logging mode...' ) ;
47+ const jsonLogger = await metalog . openLog ( {
48+ path : './log' ,
49+ workerId : 7 ,
50+ writeInterval : 3000 ,
51+ writeBuffer : 64 * 1024 ,
52+ keepDays : 5 ,
53+ home : process . cwd ( ) ,
54+ json : true ,
55+ } ) ;
56+
57+ await testConsoleMethods ( jsonLogger ) ;
58+ await jsonLogger . close ( ) ;
59+ } ;
4060
41- logger . close ( ) ;
42- } ) ( ) ;
61+ run ( ) ;
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ const createLogger = () =>
1414 home : process . cwd ( ) ,
1515 } ) ;
1616
17- ( async ( ) => {
17+ const run = async ( ) => {
1818 const logger1 = await createLogger ( ) ;
1919 const { console } = logger1 ;
2020
@@ -124,4 +124,6 @@ const createLogger = () =>
124124 if ( msg . includes ( dir ) ) throw new Error ( 'Path truncation error' ) ;
125125 await logger . close ( ) ;
126126 } ) ;
127- } ) ( ) ;
127+ } ;
128+
129+ run ( ) ;
You can’t perform that action at this time.
0 commit comments