@@ -52,10 +52,10 @@ export interface FileHandlerOptions extends BaseHandlerOptions {
52
52
* This handler requires `--allow-write` permission on the log file.
53
53
*
54
54
* @example Usage
55
- * ```ts no-assert ignore
55
+ * ```ts no-assert
56
56
* import { FileHandler } from "@std/log/file-handler";
57
57
*
58
- * const handler = new FileHandler("INFO", { filename: "./logs.txt" });
58
+ * const handler = new FileHandler("INFO", { filename: "./_tmp/ logs.txt" });
59
59
* handler.setup();
60
60
* handler.log('Hello, world!'); // Buffers the message, or writes it to the file depending on buffer state
61
61
* handler.flush(); // Manually flushes the buffer
@@ -64,95 +64,44 @@ export interface FileHandlerOptions extends BaseHandlerOptions {
64
64
*/
65
65
export class FileHandler extends BaseHandler {
66
66
/** Opened file to append logs to.
67
- * @example Usage
68
- * ```ts no-assert ignore
69
- * import { FileHandler } from "@std/log/file-handler";
70
67
*
71
- * const handler = new FileHandler("INFO", { filename: "./logs.txt" });
72
- * handler.setup();
73
- * handler.log('Hello, world!'); // Buffers the message, or writes it to the file depending on buffer state
74
- * handler.flush(); // Manually flushes the buffer
75
- * handler.destroy(); // Closes the file and removes listeners
76
- * ```
77
- * **/
68
+ * @private
69
+ */
78
70
[ fileSymbol ] : Deno . FsFile | undefined ;
79
71
/** Buffer used to write to file.
80
- * @example Usage
81
- * ```ts no-assert ignore
82
- * import { FileHandler } from "@std/log/file-handler";
83
72
*
84
- * const handler = new FileHandler("INFO", { filename: "./logs.txt" });
85
- * handler.setup();
86
- * handler.log('Hello, world!'); // Buffers the message, or writes it to the file depending on buffer state
87
- * handler.flush(); // Manually flushes the buffer
88
- * handler.destroy(); // Closes the file and removes listeners
89
- * ```
90
- * **/
73
+ * @private
74
+ */
91
75
[ bufSymbol ] : Uint8Array ;
92
- /** Current position for pointer.
93
- * @example Usage
94
- * ```ts no-assert ignore
95
- * import { FileHandler } from "@std/log/file-handler";
76
+ /**
77
+ * Current position for pointer.
96
78
*
97
- * const handler = new FileHandler("INFO", { filename: "./logs.txt" });
98
- * handler.setup();
99
- * handler.log('Hello, world!'); // Buffers the message, or writes it to the file depending on buffer state
100
- * handler.flush(); // Manually flushes the buffer
101
- * handler.destroy(); // Closes the file and removes listeners
102
- * ```
103
- * **/
79
+ * @private
80
+ */
104
81
[ pointerSymbol ] = 0 ;
105
- /** Filename associated with the file being logged.
106
- * @example Usage
107
- * ```ts no-assert ignore
108
- * import { FileHandler } from "@std/log/file-handler";
82
+ /**
83
+ * Filename associated with the file being logged.
109
84
*
110
- * const handler = new FileHandler("INFO", { filename: "./logs.txt" });
111
- * handler.setup();
112
- * handler.log('Hello, world!'); // Buffers the message, or writes it to the file depending on buffer state
113
- * handler.flush(); // Manually flushes the buffer
114
- * handler.destroy(); // Closes the file and removes listeners
115
- * ```
116
- * **/
85
+ * @private
86
+ */
117
87
[ filenameSymbol ] : string ;
118
- /** Current log mode.
119
- * @example Usage
120
- * ```ts no-assert ignore
121
- * import { FileHandler } from "@std/log/file-handler";
88
+ /**
89
+ * Current log mode.
122
90
*
123
- * const handler = new FileHandler("INFO", { filename: "./logs.txt" });
124
- * handler.setup();
125
- * handler.log('Hello, world!'); // Buffers the message, or writes it to the file depending on buffer state
126
- * handler.flush(); // Manually flushes the buffer
127
- * handler.destroy(); // Closes the file and removes listeners
128
- * ```
129
- * **/
91
+ * @private
92
+ */
130
93
[ modeSymbol ] : LogMode ;
131
- /** File open options.
132
- * @example Usage
133
- * ```ts no-assert ignore
134
- * import { FileHandler } from "@std/log/file-handler";
94
+ /**
95
+ * File open options.
135
96
*
136
- * const handler = new FileHandler("INFO", { filename: "./logs.txt" });
137
- * handler.setup();
138
- * handler.log('Hello, world!'); // Buffers the message, or writes it to the file depending on buffer state
139
- * handler.flush(); // Manually flushes the buffer
140
- * handler.destroy(); // Closes the file and removes listeners
141
- * ```
142
- * **/
97
+ * @private
98
+ */
143
99
[ openOptionsSymbol ] : Deno . OpenOptions ;
144
- /** Text encoder.
145
- * @example Usage
146
- * ```ts no-assert ignore
147
- * import { FileHandler } from "@std/log/file-handler";
100
+ /**
101
+ * Text encoder.
148
102
*
149
- * const handler = new FileHandler("INFO", { filename: "./logs.txt" });
150
- * handler.setup();
151
- * handler.log('Hello, world!'); // Buffers the message, or writes it to the file depending on buffer state
152
- * handler.flush(); // Manually flushes the buffer
153
- * handler.destroy(); // Closes the file and removes listeners
154
- * ```
155
- * **/
103
+ * @private
104
+ */
156
105
[ encoderSymbol ] : TextEncoder = new TextEncoder ( ) ;
157
106
#unloadCallback = ( ( ) => {
158
107
this . destroy ( ) ;
@@ -183,10 +132,10 @@ export class FileHandler extends BaseHandler {
183
132
* Sets up the file handler by opening the specified file and initializing resources.
184
133
*
185
134
* @example Usage
186
- * ```ts no-assert ignore
135
+ * ```ts no-assert
187
136
* import { FileHandler } from "@std/log/file-handler";
188
137
*
189
- * const handler = new FileHandler("INFO", { filename: "./logs.txt" });
138
+ * const handler = new FileHandler("INFO", { filename: "./_tmp/ logs.txt" });
190
139
* handler.setup(); // Opens the file and prepares the handler for logging.
191
140
* handler.destroy();
192
141
* ```
@@ -207,13 +156,13 @@ export class FileHandler extends BaseHandler {
207
156
* @param logRecord Log record to handle.
208
157
*
209
158
* @example Usage
210
- * ```ts ignore
159
+ * ```ts
211
160
* import { FileHandler } from "@std/log/file-handler";
212
161
* import { assertInstanceOf } from "@std/assert/instance-of";
213
162
* import { LogLevels } from "./levels.ts";
214
163
* import { LogRecord } from "./logger.ts";
215
164
*
216
- * const handler = new FileHandler("INFO", { filename: "./logs.txt" });
165
+ * const handler = new FileHandler("INFO", { filename: "./_tmp/ logs.txt" });
217
166
* handler.setup();
218
167
*
219
168
* // Flushes the buffer immediately and logs "CRITICAL This log is very critical indeed." into the file.
@@ -245,11 +194,11 @@ export class FileHandler extends BaseHandler {
245
194
* @param msg The message to log.
246
195
*
247
196
* @example Usage
248
- * ```ts ignore
197
+ * ```ts
249
198
* import { FileHandler } from "@std/log/file-handler";
250
199
* import { assertInstanceOf } from "@std/assert/instance-of";
251
200
*
252
- * const handler = new FileHandler("INFO", { filename: "./logs.txt" });
201
+ * const handler = new FileHandler("INFO", { filename: "./_tmp/ logs.txt" });
253
202
* handler.setup();
254
203
* handler.log('Hello, world!');
255
204
* handler.flush();
@@ -275,11 +224,11 @@ export class FileHandler extends BaseHandler {
275
224
* Immediately writes the contents of the buffer to the previously opened file.
276
225
*
277
226
* @example Usage
278
- * ```ts ignore
227
+ * ```ts
279
228
* import { FileHandler } from "@std/log/file-handler";
280
229
* import { assertInstanceOf } from "@std/assert/instance-of";
281
230
*
282
- * const handler = new FileHandler("INFO", { filename: "./logs.txt" });
231
+ * const handler = new FileHandler("INFO", { filename: "./_tmp/ logs.txt" });
283
232
* handler.setup();
284
233
* handler.log('Hello, world!');
285
234
* handler.flush(); // Writes buffered log messages to the file immediately.
@@ -308,11 +257,11 @@ export class FileHandler extends BaseHandler {
308
257
* Destroys the handler, performing any cleanup that is required and closes the file handler.
309
258
*
310
259
* @example Usage
311
- * ```ts ignore
260
+ * ```ts
312
261
* import { FileHandler } from "@std/log/file-handler";
313
262
* import { assertInstanceOf } from "@std/assert/instance-of";
314
263
*
315
- * const handler = new FileHandler("INFO", { filename: "./logs.txt" });
264
+ * const handler = new FileHandler("INFO", { filename: "./_tmp/ logs.txt" });
316
265
* handler.setup();
317
266
* handler.destroy();
318
267
*
0 commit comments