@julanzw/ttoolbox-discordjs-framework 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -25,9 +25,9 @@ import { ILogger, LoggerOptions } from '../types/logger.js';
|
|
|
25
25
|
* ```
|
|
26
26
|
*/
|
|
27
27
|
export declare class TToolboxLogger implements ILogger {
|
|
28
|
-
private logFilePath;
|
|
29
28
|
private levels;
|
|
30
29
|
private reset;
|
|
30
|
+
protected logFilePath: string;
|
|
31
31
|
private static readonly DEFAULT_LEVELS;
|
|
32
32
|
/**
|
|
33
33
|
* Creates a new TToolboxLogger instance.
|
|
@@ -157,20 +157,16 @@ export declare class TToolboxLogger implements ILogger {
|
|
|
157
157
|
*/
|
|
158
158
|
clearLog(): void;
|
|
159
159
|
/**
|
|
160
|
-
* Creates a new log file with a timestamp-based name
|
|
160
|
+
* Creates a new log file with a timestamp-based name.
|
|
161
|
+
* Modifies this logger instance to write to the new file.
|
|
161
162
|
*
|
|
162
|
-
*
|
|
163
|
-
*
|
|
164
|
-
* @returns A new TToolboxLogger instance pointing to the new log file
|
|
163
|
+
* @returns This logger instance with the new filepath
|
|
165
164
|
*
|
|
166
165
|
* @example
|
|
167
166
|
* ```typescript
|
|
168
|
-
*
|
|
169
|
-
*
|
|
170
|
-
*
|
|
171
|
-
* // Later, create a new log file
|
|
172
|
-
* logger = logger.rotate();
|
|
167
|
+
* logger.rotate();
|
|
168
|
+
* logger.info('New log file started', 'logger');
|
|
173
169
|
* ```
|
|
174
170
|
*/
|
|
175
|
-
rotate():
|
|
171
|
+
rotate(): this;
|
|
176
172
|
}
|
|
@@ -217,31 +217,23 @@ export class TToolboxLogger {
|
|
|
217
217
|
fs.writeFileSync(this.logFilePath, '', 'utf8');
|
|
218
218
|
}
|
|
219
219
|
/**
|
|
220
|
-
* Creates a new log file with a timestamp-based name
|
|
220
|
+
* Creates a new log file with a timestamp-based name.
|
|
221
|
+
* Modifies this logger instance to write to the new file.
|
|
221
222
|
*
|
|
222
|
-
*
|
|
223
|
-
*
|
|
224
|
-
* @returns A new TToolboxLogger instance pointing to the new log file
|
|
223
|
+
* @returns This logger instance with the new filepath
|
|
225
224
|
*
|
|
226
225
|
* @example
|
|
227
226
|
* ```typescript
|
|
228
|
-
*
|
|
229
|
-
*
|
|
230
|
-
*
|
|
231
|
-
* // Later, create a new log file
|
|
232
|
-
* logger = logger.rotate();
|
|
227
|
+
* logger.rotate();
|
|
228
|
+
* logger.info('New log file started', 'logger');
|
|
233
229
|
* ```
|
|
234
230
|
*/
|
|
235
231
|
rotate() {
|
|
236
232
|
const timestamp = formatDateToYYYYMMDDHHMMSS(new Date());
|
|
237
233
|
const logDir = path.dirname(this.logFilePath);
|
|
238
234
|
const newFileName = `log-${timestamp}.log`;
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
logFileName: newFileName,
|
|
242
|
-
customLevels: this.levels,
|
|
243
|
-
extendDefaultLevels: false,
|
|
244
|
-
});
|
|
235
|
+
this.logFilePath = path.join(logDir, newFileName);
|
|
236
|
+
return this;
|
|
245
237
|
}
|
|
246
238
|
}
|
|
247
239
|
// Default log levels
|
package/package.json
CHANGED