diff --git a/chapters/ch04.2-writing-logs.md b/chapters/ch04.2-writing-logs.md index 256498d..9c0d6c2 100644 --- a/chapters/ch04.2-writing-logs.md +++ b/chapters/ch04.2-writing-logs.md @@ -754,7 +754,7 @@ class Logger { } // write logs to the opened file - await this.#log_file_handle.write(log_message); + await this.#log_file_handle.write(message); } ... } diff --git a/chapters/ch04.5-rolling-file-support.md b/chapters/ch04.5-rolling-file-support.md index d5d5f1a..6b4b437 100644 --- a/chapters/ch04.5-rolling-file-support.md +++ b/chapters/ch04.5-rolling-file-support.md @@ -131,7 +131,7 @@ const current_time = new Date().getTime(); We are creating a new `Date` object and uses the `getTime()` method to obtain the current time in milliseconds since epoch. ```js -if (size >= size_threshold || (current_time - birthtimeMs >= time_threshold)) { +if (size >= size_threshold || (current_time - birthtimeMs >= time_threshold * 1000)) { ``` We'll be creating a new file: @@ -478,19 +478,19 @@ Run the `test.js` script. You'll notice a new file created every now and then. L ```bash $ ls -al ./logs -.rw-r--r-- 10k ishtmeet 22 Aug 06:11 Logtar_2023-08-22T00-41-58-132Z.log -.rw-r--r-- 10k ishtmeet 22 Aug 06:12 Logtar_2023-08-22T00-41-59-232Z.log -.rw-r--r-- 10k ishtmeet 22 Aug 06:12 Logtar_2023-08-22T00-42-01-101Z.log -.rw-r--r-- 10k ishtmeet 22 Aug 06:12 Logtar_2023-08-22T00-42-02-139Z.log -.rw-r--r-- 10k ishtmeet 22 Aug 06:12 Logtar_2023-08-22T00-42-03-545Z.log -.rw-r--r-- 10k ishtmeet 22 Aug 06:12 Logtar_2023-08-22T00-42-04-132Z.log -.rw-r--r-- 10k ishtmeet 22 Aug 06:12 Logtar_2023-08-22T00-42-05-382Z.log -.rw-r--r-- 10k ishtmeet 22 Aug 06:12 Logtar_2023-08-22T00-42-06-432Z.log -.rw-r--r-- 10k ishtmeet 22 Aug 06:12 Logtar_2023-08-22T00-42-07-109Z.log +.rw-r--r-- 20k ishtmeet 22 Aug 06:11 Logtar_2023-08-22T00-41-58-132Z.log +.rw-r--r-- 20k ishtmeet 22 Aug 06:12 Logtar_2023-08-22T00-41-59-232Z.log +.rw-r--r-- 20k ishtmeet 22 Aug 06:12 Logtar_2023-08-22T00-42-01-101Z.log +.rw-r--r-- 20k ishtmeet 22 Aug 06:12 Logtar_2023-08-22T00-42-02-139Z.log +.rw-r--r-- 20k ishtmeet 22 Aug 06:12 Logtar_2023-08-22T00-42-03-545Z.log +.rw-r--r-- 20k ishtmeet 22 Aug 06:12 Logtar_2023-08-22T00-42-04-132Z.log +.rw-r--r-- 20k ishtmeet 22 Aug 06:12 Logtar_2023-08-22T00-42-05-382Z.log +.rw-r--r-- 20k ishtmeet 22 Aug 06:12 Logtar_2023-08-22T00-42-06-432Z.log +.rw-r--r-- 20k ishtmeet 22 Aug 06:12 Logtar_2023-08-22T00-42-07-109Z.log .rw-r--r-- 3.6k ishtmeet 22 Aug 06:12 Logtar_2023-08-22T00-42-08-138Z.log ``` -Each file is only 10KB, which is exactly what we need. However, the last file is not 10KB because I had to exit the infinite loop caused by `setInterval` by pressing `Ctrl + C`. +Each file is only 20KB, which is exactly what we need. However, the last file is not 20KB because I had to exit the infinite loop caused by `setInterval` by pressing `Ctrl + C`. We now have an actual logging library that can be used with any type of project. However, there is still something we need to take care of: providing a middleware function that can be used.