@@ -410,7 +410,7 @@ class Logger {
410
410
#log_file_handle;
411
411
412
412
async init () {
413
- const file_name = this .#config .file_prefix + new Date ().toISOString ().replace (/ \. . + / , " " ) + " .log" ;
413
+ const file_name = this .#config .file_prefix + new Date ().toISOString ().replace (/ [ \. :] + / , " - " ) + " .log" ;
414
414
this .#log_file_handle = await fs .open (file_name, " a+" );
415
415
}
416
416
}
@@ -467,7 +467,7 @@ class Logger {
467
467
...
468
468
469
469
async init () {
470
- const file_name = this .#config .file_prefix + new Date ().toISOString ().replace (/ \. . + / , " " ) + " .log" ;
470
+ const file_name = this .#config .file_prefix + new Date ().toISOString ().replace (/ [ \. :] + / , " - " ) + " .log" ;
471
471
this .#log_file_handle = await fs .open (file_name, " a+" );
472
472
console .log (" File created." )
473
473
}
@@ -602,7 +602,7 @@ Update the code inside `Logger.init` method:
602
602
const path = require (' node:path' )
603
603
604
604
async init () {
605
- const file_name = this .#config .file_prefix + new Date ().toISOString ().replace (/ \. . + / , " " ) + " .log" ;
605
+ const file_name = this .#config .file_prefix + new Date ().toISOString ().replace (/ [ \. :] + / , " - " ) + " .log" ;
606
606
this .#log_file_handle = await fs .open (path .join (' logs' , file_name), " a+" );
607
607
}
608
608
```
@@ -699,7 +699,7 @@ Let's go through the `check_and_create_dir` function's code line by line.
699
699
async init () {
700
700
const log_dir_path = check_and_create_dir (" logs" )
701
701
702
- const file_name = this .#config .file_prefix + new Date ().toISOString ().replace (/ \. . + / , " " ) + " .log" ;
702
+ const file_name = this .#config .file_prefix + new Date ().toISOString ().replace (/ [ \. :] + / , " - " ) + " .log" ;
703
703
704
704
// Open/Create the file at the specified log directory and
705
705
// save the file handle to the `#log_file_handle` for further
@@ -793,4 +793,4 @@ We'll take care of all this in the next chapter.
793
793
794
794
[ ![ Read Next] ( /assets/imgs/next.png )] ( /chapters/ch04.3-capturing-metadata.md )
795
795
796
- ![ ] ( https://uddrapi.com/api/img?page=ch04.2 )
796
+ ![ ] ( https://uddrapi.com/api/img?page=ch04.2 )
0 commit comments