@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 and returns a new logger instance.
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
- * Useful for log rotation - creates a new file while keeping the old one.
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
- * // Rotate logs daily
169
- * let logger = new TToolboxLogger('./logs');
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(): TToolboxLogger;
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 and returns a new logger instance.
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
- * Useful for log rotation - creates a new file while keeping the old one.
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
- * // Rotate logs daily
229
- * let logger = new TToolboxLogger('./logs');
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
- return new TToolboxLogger({
240
- logDir,
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@julanzw/ttoolbox-discordjs-framework",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "A Discord.js command framework with built-in handlers and utilities",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",