@@ -12,9 +12,11 @@ process.env.DEBUG_HIDE_DATE = "yes"; // since we supply it ourselves
12
12
// otherwise, maybe stuff like this works: (debug as any).inspectOpts["hideDate"] = true;
13
13
14
14
import debug , { Debugger } from "debug" ;
15
- import { mkdirSync , createWriteStream , statSync , ftruncate } from "fs" ;
16
- import { format } from "util" ;
17
- import { dirname , join } from "path" ;
15
+
16
+ import { createWriteStream , ftruncate , mkdirSync , statSync } from "node:fs" ;
17
+ import { dirname , join } from "node:path" ;
18
+ import { format } from "node:util" ;
19
+
18
20
import { logs } from "./data" ;
19
21
20
22
const MAX_FILE_SIZE_BYTES = 20 * 1024 * 1024 ; // 20MB
@@ -25,12 +27,12 @@ let _trimLogFileSizePath = "";
25
27
export function trimLogFileSize ( ) {
26
28
// THIS JUST DOESN'T REALLY WORK!
27
29
return ;
28
-
30
+
29
31
if ( ! _trimLogFileSizePath ) return ;
30
32
let stats ;
31
33
try {
32
34
stats = statSync ( _trimLogFileSizePath ) ;
33
- } catch ( _ ) {
35
+ } catch ( _ ) {
34
36
// this happens if the file doesn't exist, which is fine since "trimming" it would be a no-op
35
37
return ;
36
38
}
@@ -141,27 +143,27 @@ function initTransports() {
141
143
142
144
initTransports ( ) ;
143
145
144
- const DEBUGGERS = {
145
- error : COCALC . extend ( "error" ) ,
146
- warn : COCALC . extend ( "warn" ) ,
147
- info : COCALC . extend ( "info" ) ,
148
- http : COCALC . extend ( "http" ) ,
149
- verbose : COCALC . extend ( "verbose" ) ,
150
- debug : COCALC . extend ( "debug" ) ,
151
- silly : COCALC . extend ( "silly" ) ,
152
- } ;
153
-
154
- type Level = keyof typeof DEBUGGERS ;
155
-
156
- const LEVELS : Level [ ] = [
146
+ const LEVELS = [
157
147
"error" ,
158
148
"warn" ,
159
149
"info" ,
160
150
"http" ,
161
151
"verbose" ,
162
152
"debug" ,
163
153
"silly" ,
164
- ] ;
154
+ ] as const ;
155
+
156
+ type Level = ( typeof LEVELS ) [ number ] ;
157
+
158
+ const DEBUGGERS : { [ key in Level ] : Debugger } = {
159
+ error : COCALC . extend ( "error" ) ,
160
+ warn : COCALC . extend ( "warn" ) ,
161
+ info : COCALC . extend ( "info" ) ,
162
+ http : COCALC . extend ( "http" ) ,
163
+ verbose : COCALC . extend ( "verbose" ) ,
164
+ debug : COCALC . extend ( "debug" ) ,
165
+ silly : COCALC . extend ( "silly" ) ,
166
+ } as const ;
165
167
166
168
class Logger {
167
169
private name : string ;
@@ -194,13 +196,13 @@ class Logger {
194
196
}
195
197
196
198
export interface WinstonLogger {
197
- error : Function ;
198
- warn : Function ;
199
- info : Function ;
200
- http : Function ;
201
- verbose : Function ;
202
- debug : Function ;
203
- silly : Function ;
199
+ error : Debugger ;
200
+ warn : Debugger ;
201
+ info : Debugger ;
202
+ http : Debugger ;
203
+ verbose : Debugger ;
204
+ debug : Debugger ;
205
+ silly : Debugger ;
204
206
extend : ( name : string ) => WinstonLogger ;
205
207
isEnabled : ( level : Level ) => boolean ;
206
208
}
0 commit comments