@logtape/file 2.2.0-dev.679 → 2.2.0-dev.683

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.
@@ -67,12 +67,20 @@ function getRotationKey(date, interval) {
67
67
  case "weekly": return `${getISOWeekYear(date)}-${getISOWeek(date)}`;
68
68
  }
69
69
  }
70
+ function getRotationIntervalMs(interval) {
71
+ switch (interval) {
72
+ case "hourly": return 60 * 60 * 1e3;
73
+ case "daily": return 24 * 60 * 60 * 1e3;
74
+ case "weekly": return 7 * 24 * 60 * 60 * 1e3;
75
+ }
76
+ }
70
77
  function getBaseTimeRotatingFileSink(options) {
71
78
  const formatter = options.formatter ?? __logtape_logtape.defaultTextFormatter;
72
79
  const encoder = options.encoder ?? new TextEncoder();
73
80
  const interval = options.interval ?? "daily";
74
81
  const filenameGenerator = options.filename ?? getDefaultFilename(interval);
75
82
  const maxAgeMs = options.maxAgeMs;
83
+ const cleanupInterval = maxAgeMs === void 0 ? getRotationIntervalMs(interval) : Math.min(getRotationIntervalMs(interval), maxAgeMs);
76
84
  const bufferSize = options.bufferSize ?? 1024 * 8;
77
85
  const flushInterval = options.flushInterval ?? 5e3;
78
86
  const directory = options.directory;
@@ -84,6 +92,7 @@ function getBaseTimeRotatingFileSink(options) {
84
92
  let currentRotationKey = getRotationKey(/* @__PURE__ */ new Date(), interval);
85
93
  let fd = options.openSync(currentPath);
86
94
  let lastFlushTimestamp = Date.now();
95
+ let lastCleanupTimestamp;
87
96
  let buffer = "";
88
97
  function shouldRotate() {
89
98
  const now = /* @__PURE__ */ new Date();
@@ -101,6 +110,8 @@ function getBaseTimeRotatingFileSink(options) {
101
110
  function cleanupOldFiles() {
102
111
  if (maxAgeMs === void 0) return;
103
112
  const now = Date.now();
113
+ if (lastCleanupTimestamp !== void 0 && cleanupInterval > 0 && now - lastCleanupTimestamp < cleanupInterval) return;
114
+ lastCleanupTimestamp = now;
104
115
  let files;
105
116
  try {
106
117
  files = options.readdirSync(directory);
@@ -110,7 +121,6 @@ function getBaseTimeRotatingFileSink(options) {
110
121
  for (const file of files) {
111
122
  if (!file.endsWith(".log")) continue;
112
123
  if (file === currentFilename) continue;
113
- const filePath = options.joinPath(directory, file);
114
124
  const dateMatch = file.match(/^(\d{4})-(\d{2})-(\d{2})(?:-(\d{2}))?\.log$/);
115
125
  const weekMatch = file.match(/^(\d{4})-W(\d{2})\.log$/);
116
126
  let fileDate = null;
@@ -124,9 +134,12 @@ function getBaseTimeRotatingFileSink(options) {
124
134
  fileDate = new Date(jan4);
125
135
  fileDate.setDate(jan4.getDate() - dayOfWeek + 1 + (parseInt(week, 10) - 1) * 7);
126
136
  }
127
- if (fileDate && now - fileDate.getTime() > maxAgeMs) try {
128
- options.unlinkSync(filePath);
129
- } catch {}
137
+ if (fileDate && now - fileDate.getTime() > maxAgeMs) {
138
+ const filePath = options.joinPath(directory, file);
139
+ try {
140
+ options.unlinkSync(filePath);
141
+ } catch {}
142
+ }
130
143
  }
131
144
  }
132
145
  if (!options.nonBlocking) {
@@ -66,12 +66,20 @@ function getRotationKey(date, interval) {
66
66
  case "weekly": return `${getISOWeekYear(date)}-${getISOWeek(date)}`;
67
67
  }
68
68
  }
69
+ function getRotationIntervalMs(interval) {
70
+ switch (interval) {
71
+ case "hourly": return 60 * 60 * 1e3;
72
+ case "daily": return 24 * 60 * 60 * 1e3;
73
+ case "weekly": return 7 * 24 * 60 * 60 * 1e3;
74
+ }
75
+ }
69
76
  function getBaseTimeRotatingFileSink(options) {
70
77
  const formatter = options.formatter ?? defaultTextFormatter;
71
78
  const encoder = options.encoder ?? new TextEncoder();
72
79
  const interval = options.interval ?? "daily";
73
80
  const filenameGenerator = options.filename ?? getDefaultFilename(interval);
74
81
  const maxAgeMs = options.maxAgeMs;
82
+ const cleanupInterval = maxAgeMs === void 0 ? getRotationIntervalMs(interval) : Math.min(getRotationIntervalMs(interval), maxAgeMs);
75
83
  const bufferSize = options.bufferSize ?? 1024 * 8;
76
84
  const flushInterval = options.flushInterval ?? 5e3;
77
85
  const directory = options.directory;
@@ -83,6 +91,7 @@ function getBaseTimeRotatingFileSink(options) {
83
91
  let currentRotationKey = getRotationKey(/* @__PURE__ */ new Date(), interval);
84
92
  let fd = options.openSync(currentPath);
85
93
  let lastFlushTimestamp = Date.now();
94
+ let lastCleanupTimestamp;
86
95
  let buffer = "";
87
96
  function shouldRotate() {
88
97
  const now = /* @__PURE__ */ new Date();
@@ -100,6 +109,8 @@ function getBaseTimeRotatingFileSink(options) {
100
109
  function cleanupOldFiles() {
101
110
  if (maxAgeMs === void 0) return;
102
111
  const now = Date.now();
112
+ if (lastCleanupTimestamp !== void 0 && cleanupInterval > 0 && now - lastCleanupTimestamp < cleanupInterval) return;
113
+ lastCleanupTimestamp = now;
103
114
  let files;
104
115
  try {
105
116
  files = options.readdirSync(directory);
@@ -109,7 +120,6 @@ function getBaseTimeRotatingFileSink(options) {
109
120
  for (const file of files) {
110
121
  if (!file.endsWith(".log")) continue;
111
122
  if (file === currentFilename) continue;
112
- const filePath = options.joinPath(directory, file);
113
123
  const dateMatch = file.match(/^(\d{4})-(\d{2})-(\d{2})(?:-(\d{2}))?\.log$/);
114
124
  const weekMatch = file.match(/^(\d{4})-W(\d{2})\.log$/);
115
125
  let fileDate = null;
@@ -123,9 +133,12 @@ function getBaseTimeRotatingFileSink(options) {
123
133
  fileDate = new Date(jan4);
124
134
  fileDate.setDate(jan4.getDate() - dayOfWeek + 1 + (parseInt(week, 10) - 1) * 7);
125
135
  }
126
- if (fileDate && now - fileDate.getTime() > maxAgeMs) try {
127
- options.unlinkSync(filePath);
128
- } catch {}
136
+ if (fileDate && now - fileDate.getTime() > maxAgeMs) {
137
+ const filePath = options.joinPath(directory, file);
138
+ try {
139
+ options.unlinkSync(filePath);
140
+ } catch {}
141
+ }
129
142
  }
130
143
  }
131
144
  if (!options.nonBlocking) {
@@ -1 +1 @@
1
- {"version":3,"file":"timefilesink.js","names":["date: Date","interval: TimeRotationInterval","options:\n & TimeRotatingFileSinkOptions\n & (\n | TimeRotatingFileSinkDriver<TFile>\n | AsyncTimeRotatingFileSinkDriver<TFile>\n )","currentFilename: string","currentPath: string","currentRotationKey: string","fd: TFile","lastFlushTimestamp: number","buffer: string","files: string[]","fileDate: Date | null","flushBuffer","sink: Sink & Disposable","record: LogRecord","activeFlush: Promise<void> | null","flushTimer: ReturnType<typeof setInterval> | null","nonBlockingSink: Sink & AsyncDisposable"],"sources":["../src/timefilesink.ts"],"sourcesContent":["import {\n defaultTextFormatter,\n type LogRecord,\n type Sink,\n} from \"@logtape/logtape\";\nimport type {\n AsyncFileSinkDriver,\n FileSinkDriver,\n FileSinkOptions,\n} from \"./filesink.base.ts\";\n\n/**\n * The rotation interval for time-based file sinks.\n */\nexport type TimeRotationInterval = \"hourly\" | \"daily\" | \"weekly\";\n\n/**\n * Options for the {@link getBaseTimeRotatingFileSink} function.\n */\nexport interface TimeRotatingFileSinkOptions\n extends Omit<FileSinkOptions, \"lazy\"> {\n /**\n * The directory to write log files to.\n */\n directory: string;\n\n /**\n * A function that generates the filename for the log file based on the date.\n * Default depends on `interval`:\n * - `\"daily\"`: `YYYY-MM-DD.log` (e.g., `2025-01-15.log`)\n * - `\"hourly\"`: `YYYY-MM-DD-HH.log` (e.g., `2025-01-15-09.log`)\n * - `\"weekly\"`: `YYYY-WW.log` (e.g., `2025-W03.log`)\n */\n filename?: (date: Date) => string;\n\n /**\n * The rotation interval. Defaults to `\"daily\"`.\n */\n interval?: TimeRotationInterval;\n\n /**\n * The maximum age of log files in milliseconds. Files older than this\n * will be deleted. If not specified, old files are not deleted.\n */\n maxAgeMs?: number;\n}\n\n/**\n * A platform-specific time-rotating file sink driver.\n */\nexport interface TimeRotatingFileSinkDriver<TFile>\n extends FileSinkDriver<TFile> {\n /**\n * Read the contents of a directory.\n * @param path A path to the directory.\n * @returns An array of filenames in the directory.\n */\n readdirSync(path: string): string[];\n\n /**\n * Delete a file.\n * @param path A path to the file to delete.\n */\n unlinkSync(path: string): void;\n\n /**\n * Create a directory if it doesn't exist.\n * @param path A path to the directory to create.\n * @param options Options for directory creation.\n */\n mkdirSync(path: string, options?: { recursive?: boolean }): void;\n\n /**\n * Join path segments.\n * @param paths Path segments to join.\n * @returns The joined path.\n */\n joinPath(...paths: string[]): string;\n}\n\n/**\n * A platform-specific async time-rotating file sink driver.\n * @since 2.0.0\n */\nexport interface AsyncTimeRotatingFileSinkDriver<TFile>\n extends AsyncFileSinkDriver<TFile> {\n /**\n * Read the contents of a directory.\n * @param path A path to the directory.\n * @returns An array of filenames in the directory.\n */\n readdirSync(path: string): string[];\n\n /**\n * Delete a file.\n * @param path A path to the file to delete.\n */\n unlinkSync(path: string): void;\n\n /**\n * Create a directory if it doesn't exist.\n * @param path A path to the directory to create.\n * @param options Options for directory creation.\n */\n mkdirSync(path: string, options?: { recursive?: boolean }): void;\n\n /**\n * Join path segments.\n * @param paths Path segments to join.\n * @returns The joined path.\n */\n joinPath(...paths: string[]): string;\n}\n\n/**\n * Get the ISO week number of a date.\n * @param date The date to get the week number of.\n * @returns The ISO week number (1-53).\n */\nexport function getISOWeek(date: Date): number {\n const d = new Date(\n Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()),\n );\n const dayNum = d.getUTCDay() || 7;\n d.setUTCDate(d.getUTCDate() + 4 - dayNum);\n const yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));\n return Math.ceil(((d.getTime() - yearStart.getTime()) / 86400000 + 1) / 7);\n}\n\n/**\n * Get the ISO week year of a date. This may differ from the calendar year\n * for dates near the start or end of a year.\n * @param date The date to get the ISO week year of.\n * @returns The ISO week year.\n */\nexport function getISOWeekYear(date: Date): number {\n const d = new Date(\n Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()),\n );\n const dayNum = d.getUTCDay() || 7;\n d.setUTCDate(d.getUTCDate() + 4 - dayNum);\n return d.getUTCFullYear();\n}\n\n/**\n * Get the default filename generator for the given interval.\n * @param interval The rotation interval.\n * @returns A function that generates a filename for a given date.\n */\nexport function getDefaultFilename(\n interval: TimeRotationInterval,\n): (date: Date) => string {\n switch (interval) {\n case \"hourly\":\n return (date: Date): string => {\n const yyyy = date.getFullYear();\n const mm = String(date.getMonth() + 1).padStart(2, \"0\");\n const dd = String(date.getDate()).padStart(2, \"0\");\n const hh = String(date.getHours()).padStart(2, \"0\");\n return `${yyyy}-${mm}-${dd}-${hh}.log`;\n };\n case \"daily\":\n return (date: Date): string => {\n const yyyy = date.getFullYear();\n const mm = String(date.getMonth() + 1).padStart(2, \"0\");\n const dd = String(date.getDate()).padStart(2, \"0\");\n return `${yyyy}-${mm}-${dd}.log`;\n };\n case \"weekly\":\n return (date: Date): string => {\n const yyyy = getISOWeekYear(date);\n const week = getISOWeek(date);\n return `${yyyy}-W${String(week).padStart(2, \"0\")}.log`;\n };\n }\n}\n\n/**\n * Get the rotation key for the given date and interval.\n * The key is used to determine when to rotate to a new file.\n * @param date The date to get the rotation key of.\n * @param interval The rotation interval.\n * @returns A string key that changes when rotation should occur.\n */\nfunction getRotationKey(date: Date, interval: TimeRotationInterval): string {\n switch (interval) {\n case \"hourly\":\n return `${date.getFullYear()}-${date.getMonth()}-${date.getDate()}-${date.getHours()}`;\n case \"daily\":\n return `${date.getFullYear()}-${date.getMonth()}-${date.getDate()}`;\n case \"weekly\":\n return `${getISOWeekYear(date)}-${getISOWeek(date)}`;\n }\n}\n\n/**\n * Get a platform-independent time-rotating file sink.\n *\n * This sink writes log records to a file in a directory, rotating to a new\n * file based on time intervals. The filename is generated based on the\n * current date/time and the configured interval.\n *\n * @template TFile The type of the file descriptor.\n * @param options The options for the sink and the file driver.\n * @returns A sink that writes to the file. The sink is also a disposable\n * object that closes the file when disposed. If `nonBlocking` is\n * enabled, returns a sink that also implements {@link AsyncDisposable}.\n */\nexport function getBaseTimeRotatingFileSink<TFile>(\n options: TimeRotatingFileSinkOptions & TimeRotatingFileSinkDriver<TFile>,\n): Sink & Disposable;\nexport function getBaseTimeRotatingFileSink<TFile>(\n options: TimeRotatingFileSinkOptions & AsyncTimeRotatingFileSinkDriver<TFile>,\n): Sink & AsyncDisposable;\nexport function getBaseTimeRotatingFileSink<TFile>(\n options:\n & TimeRotatingFileSinkOptions\n & (\n | TimeRotatingFileSinkDriver<TFile>\n | AsyncTimeRotatingFileSinkDriver<TFile>\n ),\n): Sink & (Disposable | AsyncDisposable) {\n const formatter = options.formatter ?? defaultTextFormatter;\n const encoder = options.encoder ?? new TextEncoder();\n const interval = options.interval ?? \"daily\";\n const filenameGenerator = options.filename ?? getDefaultFilename(interval);\n const maxAgeMs = options.maxAgeMs;\n const bufferSize = options.bufferSize ?? 1024 * 8;\n const flushInterval = options.flushInterval ?? 5000;\n const directory = options.directory;\n\n // Ensure directory exists\n try {\n options.mkdirSync(directory, { recursive: true });\n } catch {\n // Directory might already exist\n }\n\n let currentFilename: string = filenameGenerator(new Date());\n let currentPath: string = options.joinPath(directory, currentFilename);\n let currentRotationKey: string = getRotationKey(new Date(), interval);\n let fd: TFile = options.openSync(currentPath);\n let lastFlushTimestamp: number = Date.now();\n let buffer: string = \"\";\n\n function shouldRotate(): boolean {\n const now = new Date();\n const newKey = getRotationKey(now, interval);\n return newKey !== currentRotationKey;\n }\n\n function performRotation(): void {\n options.closeSync(fd);\n const now = new Date();\n currentFilename = filenameGenerator(now);\n currentPath = options.joinPath(directory, currentFilename);\n currentRotationKey = getRotationKey(now, interval);\n fd = options.openSync(currentPath);\n }\n\n function cleanupOldFiles(): void {\n if (maxAgeMs === undefined) return;\n\n const now = Date.now();\n let files: string[];\n try {\n files = options.readdirSync(directory);\n } catch {\n return;\n }\n\n for (const file of files) {\n if (!file.endsWith(\".log\")) continue;\n if (file === currentFilename) continue;\n\n const filePath = options.joinPath(directory, file);\n\n // Try to parse the date from the filename\n const dateMatch = file.match(\n /^(\\d{4})-(\\d{2})-(\\d{2})(?:-(\\d{2}))?\\.log$/,\n );\n const weekMatch = file.match(/^(\\d{4})-W(\\d{2})\\.log$/);\n\n let fileDate: Date | null = null;\n\n if (dateMatch) {\n const [, year, month, day, hour] = dateMatch;\n fileDate = new Date(\n parseInt(year!, 10),\n parseInt(month!, 10) - 1,\n parseInt(day!, 10),\n hour ? parseInt(hour, 10) : 0,\n );\n } else if (weekMatch) {\n const [, year, week] = weekMatch;\n // Get the date of the first day of the week\n const jan4 = new Date(parseInt(year!, 10), 0, 4);\n const dayOfWeek = jan4.getDay() || 7;\n fileDate = new Date(jan4);\n fileDate.setDate(\n jan4.getDate() - dayOfWeek + 1 + (parseInt(week!, 10) - 1) * 7,\n );\n }\n\n if (fileDate && now - fileDate.getTime() > maxAgeMs) {\n try {\n options.unlinkSync(filePath);\n } catch {\n // Ignore errors when deleting files\n }\n }\n }\n }\n\n if (!options.nonBlocking) {\n // Blocking mode implementation\n // deno-lint-ignore no-inner-declarations\n function flushBuffer(): void {\n if (buffer.length > 0) {\n if (shouldRotate()) {\n performRotation();\n }\n const bytes = encoder.encode(buffer);\n buffer = \"\";\n options.writeSync(fd, bytes);\n options.flushSync(fd);\n lastFlushTimestamp = Date.now();\n cleanupOldFiles();\n }\n }\n\n const sink: Sink & Disposable = (record: LogRecord) => {\n buffer += formatter(record);\n\n const shouldFlushBySize = buffer.length >= bufferSize;\n const shouldFlushByTime = flushInterval > 0 &&\n (record.timestamp - lastFlushTimestamp) >= flushInterval;\n\n if (shouldFlushBySize || shouldFlushByTime) {\n flushBuffer();\n }\n };\n\n sink[Symbol.dispose] = () => {\n flushBuffer();\n options.closeSync(fd);\n };\n\n return sink;\n }\n\n // Non-blocking mode implementation\n const asyncOptions = options as AsyncTimeRotatingFileSinkDriver<TFile>;\n let disposed = false;\n let activeFlush: Promise<void> | null = null;\n let flushTimer: ReturnType<typeof setInterval> | null = null;\n\n async function flushBuffer(): Promise<void> {\n if (buffer.length === 0) return;\n\n if (shouldRotate()) {\n performRotation();\n }\n\n const data = buffer;\n buffer = \"\";\n try {\n const bytes = encoder.encode(data);\n asyncOptions.writeSync(fd, bytes);\n await asyncOptions.flush(fd);\n lastFlushTimestamp = Date.now();\n cleanupOldFiles();\n } catch {\n // Silently ignore errors in non-blocking mode\n }\n }\n\n function scheduleFlush(): void {\n if (activeFlush || disposed) return;\n\n activeFlush = flushBuffer().finally(() => {\n activeFlush = null;\n });\n }\n\n function startFlushTimer(): void {\n if (flushTimer !== null || disposed) return;\n\n flushTimer = setInterval(() => {\n scheduleFlush();\n }, flushInterval);\n }\n\n const nonBlockingSink: Sink & AsyncDisposable = (record: LogRecord) => {\n if (disposed) return;\n buffer += formatter(record);\n\n const shouldFlushBySize = buffer.length >= bufferSize;\n const shouldFlushByTime = flushInterval > 0 &&\n (record.timestamp - lastFlushTimestamp) >= flushInterval;\n\n if (shouldFlushBySize || shouldFlushByTime) {\n scheduleFlush();\n } else if (flushTimer === null && flushInterval > 0) {\n startFlushTimer();\n }\n };\n\n nonBlockingSink[Symbol.asyncDispose] = async () => {\n disposed = true;\n if (flushTimer !== null) {\n clearInterval(flushTimer);\n flushTimer = null;\n }\n await flushBuffer();\n try {\n await asyncOptions.close(fd);\n } catch {\n // Writer might already be closed or errored\n }\n };\n\n return nonBlockingSink;\n}\n"],"mappings":";;;;;;;;AAuHA,SAAgB,WAAWA,MAAoB;CAC7C,MAAM,IAAI,IAAI,KACZ,KAAK,IAAI,KAAK,aAAa,EAAE,KAAK,UAAU,EAAE,KAAK,SAAS,CAAC;CAE/D,MAAM,SAAS,EAAE,WAAW,IAAI;AAChC,GAAE,WAAW,EAAE,YAAY,GAAG,IAAI,OAAO;CACzC,MAAM,YAAY,IAAI,KAAK,KAAK,IAAI,EAAE,gBAAgB,EAAE,GAAG,EAAE;AAC7D,QAAO,KAAK,OAAO,EAAE,SAAS,GAAG,UAAU,SAAS,IAAI,QAAW,KAAK,EAAE;AAC3E;;;;;;;AAQD,SAAgB,eAAeA,MAAoB;CACjD,MAAM,IAAI,IAAI,KACZ,KAAK,IAAI,KAAK,aAAa,EAAE,KAAK,UAAU,EAAE,KAAK,SAAS,CAAC;CAE/D,M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AAC3B,kBAAa;AACb,WAAQ,UAAU,GAAG;EACtB;AAED,SAAO;CACR;CAGD,MAAM,eAAe;CACrB,IAAI,WAAW;CACf,IAAIC,cAAoC;CACxC,IAAIC,aAAoD;CAExD,eAAe,cAA6B;AAC1C,MAAI,OAAO,WAAW,EAAG;AAEzB,MAAI,cAAc,CAChB,kBAAiB;EAGnB,MAAM,OAAO;AACb,WAAS;AACT,MAAI;GACF,MAAM,QAAQ,QAAQ,OAAO,KAAK;AAClC,gBAAa,UAAU,IAAI,MAAM;AACjC,SAAM,aAAa,MAAM,GAAG;AAC5B,wBAAqB,KAAK,KAAK;AAC/B,oBAAiB;EAClB,QAAO,CAEP;CACF;CAED,SAAS,gBAAsB;AAC7B,MAAI,eAAe,SAAU;AAE7B,gBAAc,aAAa,CAAC,QAAQ,MAAM;AACxC,iBAAc;EACf,EAAC;CACH;CAED,SAAS,kBAAwB;AAC/B,MAAI,eAAe,QAAQ,SAAU;AAErC,eAAa,YAAY,MAAM;AAC7B,kBAAe;EAChB,GAAE,cAAc;CAClB;CAED,MAAMC,kBAA0C,CAACH,WAAsB;AACrE,MAAI,SAAU;AACd,YAAU,UAAU,OAAO;EAE3B,MAAM,oBAAoB,OAAO,UAAU;EAC3C,MAAM,oBAAoB,gBAAgB,KACvC,OAAO,YAAY,sBAAuB;AAE7C,MAAI,qBAAqB,kBACvB,gBAAe;WACN,eAAe,QAAQ,gBAAgB,EAChD,kBAAiB;CAEpB;AAED,iBAAgB,OAAO,gBAAgB,YAAY;AACjD,aAAW;AACX,MAAI,eAAe,MAAM;AACvB,iBAAc,WAAW;AACzB,gBAAa;EACd;AACD,QAAM,aAAa;AACnB,MAAI;AACF,SAAM,aAAa,MAAM,GAAG;EAC7B,QAAO,CAEP;CACF;AAED,QAAO;AACR"}
1
+ {"version":3,"file":"timefilesink.js","names":["date: Date","interval: TimeRotationInterval","options:\n & TimeRotatingFileSinkOptions\n & (\n | TimeRotatingFileSinkDriver<TFile>\n | AsyncTimeRotatingFileSinkDriver<TFile>\n )","currentFilename: string","currentPath: string","currentRotationKey: string","fd: TFile","lastFlushTimestamp: number","lastCleanupTimestamp: number | undefined","buffer: string","files: string[]","fileDate: Date | null","flushBuffer","sink: Sink & Disposable","record: LogRecord","activeFlush: Promise<void> | null","flushTimer: ReturnType<typeof setInterval> | null","nonBlockingSink: Sink & AsyncDisposable"],"sources":["../src/timefilesink.ts"],"sourcesContent":["import {\n defaultTextFormatter,\n type LogRecord,\n type Sink,\n} from \"@logtape/logtape\";\nimport type {\n AsyncFileSinkDriver,\n FileSinkDriver,\n FileSinkOptions,\n} from \"./filesink.base.ts\";\n\n/**\n * The rotation interval for time-based file sinks.\n */\nexport type TimeRotationInterval = \"hourly\" | \"daily\" | \"weekly\";\n\n/**\n * Options for the {@link getBaseTimeRotatingFileSink} function.\n */\nexport interface TimeRotatingFileSinkOptions\n extends Omit<FileSinkOptions, \"lazy\"> {\n /**\n * The directory to write log files to.\n */\n directory: string;\n\n /**\n * A function that generates the filename for the log file based on the date.\n * Default depends on `interval`:\n * - `\"daily\"`: `YYYY-MM-DD.log` (e.g., `2025-01-15.log`)\n * - `\"hourly\"`: `YYYY-MM-DD-HH.log` (e.g., `2025-01-15-09.log`)\n * - `\"weekly\"`: `YYYY-WW.log` (e.g., `2025-W03.log`)\n */\n filename?: (date: Date) => string;\n\n /**\n * The rotation interval. Defaults to `\"daily\"`.\n */\n interval?: TimeRotationInterval;\n\n /**\n * The maximum age of log files in milliseconds. Files older than this\n * will be deleted. If not specified, old files are not deleted.\n */\n maxAgeMs?: number;\n}\n\n/**\n * A platform-specific time-rotating file sink driver.\n */\nexport interface TimeRotatingFileSinkDriver<TFile>\n extends FileSinkDriver<TFile> {\n /**\n * Read the contents of a directory.\n * @param path A path to the directory.\n * @returns An array of filenames in the directory.\n */\n readdirSync(path: string): string[];\n\n /**\n * Delete a file.\n * @param path A path to the file to delete.\n */\n unlinkSync(path: string): void;\n\n /**\n * Create a directory if it doesn't exist.\n * @param path A path to the directory to create.\n * @param options Options for directory creation.\n */\n mkdirSync(path: string, options?: { recursive?: boolean }): void;\n\n /**\n * Join path segments.\n * @param paths Path segments to join.\n * @returns The joined path.\n */\n joinPath(...paths: string[]): string;\n}\n\n/**\n * A platform-specific async time-rotating file sink driver.\n * @since 2.0.0\n */\nexport interface AsyncTimeRotatingFileSinkDriver<TFile>\n extends AsyncFileSinkDriver<TFile> {\n /**\n * Read the contents of a directory.\n * @param path A path to the directory.\n * @returns An array of filenames in the directory.\n */\n readdirSync(path: string): string[];\n\n /**\n * Delete a file.\n * @param path A path to the file to delete.\n */\n unlinkSync(path: string): void;\n\n /**\n * Create a directory if it doesn't exist.\n * @param path A path to the directory to create.\n * @param options Options for directory creation.\n */\n mkdirSync(path: string, options?: { recursive?: boolean }): void;\n\n /**\n * Join path segments.\n * @param paths Path segments to join.\n * @returns The joined path.\n */\n joinPath(...paths: string[]): string;\n}\n\n/**\n * Get the ISO week number of a date.\n * @param date The date to get the week number of.\n * @returns The ISO week number (1-53).\n */\nexport function getISOWeek(date: Date): number {\n const d = new Date(\n Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()),\n );\n const dayNum = d.getUTCDay() || 7;\n d.setUTCDate(d.getUTCDate() + 4 - dayNum);\n const yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));\n return Math.ceil(((d.getTime() - yearStart.getTime()) / 86400000 + 1) / 7);\n}\n\n/**\n * Get the ISO week year of a date. This may differ from the calendar year\n * for dates near the start or end of a year.\n * @param date The date to get the ISO week year of.\n * @returns The ISO week year.\n */\nexport function getISOWeekYear(date: Date): number {\n const d = new Date(\n Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()),\n );\n const dayNum = d.getUTCDay() || 7;\n d.setUTCDate(d.getUTCDate() + 4 - dayNum);\n return d.getUTCFullYear();\n}\n\n/**\n * Get the default filename generator for the given interval.\n * @param interval The rotation interval.\n * @returns A function that generates a filename for a given date.\n */\nexport function getDefaultFilename(\n interval: TimeRotationInterval,\n): (date: Date) => string {\n switch (interval) {\n case \"hourly\":\n return (date: Date): string => {\n const yyyy = date.getFullYear();\n const mm = String(date.getMonth() + 1).padStart(2, \"0\");\n const dd = String(date.getDate()).padStart(2, \"0\");\n const hh = String(date.getHours()).padStart(2, \"0\");\n return `${yyyy}-${mm}-${dd}-${hh}.log`;\n };\n case \"daily\":\n return (date: Date): string => {\n const yyyy = date.getFullYear();\n const mm = String(date.getMonth() + 1).padStart(2, \"0\");\n const dd = String(date.getDate()).padStart(2, \"0\");\n return `${yyyy}-${mm}-${dd}.log`;\n };\n case \"weekly\":\n return (date: Date): string => {\n const yyyy = getISOWeekYear(date);\n const week = getISOWeek(date);\n return `${yyyy}-W${String(week).padStart(2, \"0\")}.log`;\n };\n }\n}\n\n/**\n * Get the rotation key for the given date and interval.\n * The key is used to determine when to rotate to a new file.\n * @param date The date to get the rotation key of.\n * @param interval The rotation interval.\n * @returns A string key that changes when rotation should occur.\n */\nfunction getRotationKey(date: Date, interval: TimeRotationInterval): string {\n switch (interval) {\n case \"hourly\":\n return `${date.getFullYear()}-${date.getMonth()}-${date.getDate()}-${date.getHours()}`;\n case \"daily\":\n return `${date.getFullYear()}-${date.getMonth()}-${date.getDate()}`;\n case \"weekly\":\n return `${getISOWeekYear(date)}-${getISOWeek(date)}`;\n }\n}\n\nfunction getRotationIntervalMs(interval: TimeRotationInterval): number {\n switch (interval) {\n case \"hourly\":\n return 60 * 60 * 1000;\n case \"daily\":\n return 24 * 60 * 60 * 1000;\n case \"weekly\":\n return 7 * 24 * 60 * 60 * 1000;\n }\n}\n\n/**\n * Get a platform-independent time-rotating file sink.\n *\n * This sink writes log records to a file in a directory, rotating to a new\n * file based on time intervals. The filename is generated based on the\n * current date/time and the configured interval.\n *\n * @template TFile The type of the file descriptor.\n * @param options The options for the sink and the file driver.\n * @returns A sink that writes to the file. The sink is also a disposable\n * object that closes the file when disposed. If `nonBlocking` is\n * enabled, returns a sink that also implements {@link AsyncDisposable}.\n */\nexport function getBaseTimeRotatingFileSink<TFile>(\n options: TimeRotatingFileSinkOptions & TimeRotatingFileSinkDriver<TFile>,\n): Sink & Disposable;\nexport function getBaseTimeRotatingFileSink<TFile>(\n options: TimeRotatingFileSinkOptions & AsyncTimeRotatingFileSinkDriver<TFile>,\n): Sink & AsyncDisposable;\nexport function getBaseTimeRotatingFileSink<TFile>(\n options:\n & TimeRotatingFileSinkOptions\n & (\n | TimeRotatingFileSinkDriver<TFile>\n | AsyncTimeRotatingFileSinkDriver<TFile>\n ),\n): Sink & (Disposable | AsyncDisposable) {\n const formatter = options.formatter ?? defaultTextFormatter;\n const encoder = options.encoder ?? new TextEncoder();\n const interval = options.interval ?? \"daily\";\n const filenameGenerator = options.filename ?? getDefaultFilename(interval);\n const maxAgeMs = options.maxAgeMs;\n const cleanupInterval = maxAgeMs === undefined\n ? getRotationIntervalMs(interval)\n : Math.min(getRotationIntervalMs(interval), maxAgeMs);\n const bufferSize = options.bufferSize ?? 1024 * 8;\n const flushInterval = options.flushInterval ?? 5000;\n const directory = options.directory;\n\n // Ensure directory exists\n try {\n options.mkdirSync(directory, { recursive: true });\n } catch {\n // Directory might already exist\n }\n\n let currentFilename: string = filenameGenerator(new Date());\n let currentPath: string = options.joinPath(directory, currentFilename);\n let currentRotationKey: string = getRotationKey(new Date(), interval);\n let fd: TFile = options.openSync(currentPath);\n let lastFlushTimestamp: number = Date.now();\n let lastCleanupTimestamp: number | undefined;\n let buffer: string = \"\";\n\n function shouldRotate(): boolean {\n const now = new Date();\n const newKey = getRotationKey(now, interval);\n return newKey !== currentRotationKey;\n }\n\n function performRotation(): void {\n options.closeSync(fd);\n const now = new Date();\n currentFilename = filenameGenerator(now);\n currentPath = options.joinPath(directory, currentFilename);\n currentRotationKey = getRotationKey(now, interval);\n fd = options.openSync(currentPath);\n }\n\n function cleanupOldFiles(): void {\n if (maxAgeMs === undefined) return;\n\n const now = Date.now();\n if (\n lastCleanupTimestamp !== undefined && cleanupInterval > 0 &&\n now - lastCleanupTimestamp < cleanupInterval\n ) {\n return;\n }\n lastCleanupTimestamp = now;\n\n let files: string[];\n try {\n files = options.readdirSync(directory);\n } catch {\n return;\n }\n\n for (const file of files) {\n if (!file.endsWith(\".log\")) continue;\n if (file === currentFilename) continue;\n\n // Try to parse the date from the filename\n const dateMatch = file.match(\n /^(\\d{4})-(\\d{2})-(\\d{2})(?:-(\\d{2}))?\\.log$/,\n );\n const weekMatch = file.match(/^(\\d{4})-W(\\d{2})\\.log$/);\n\n let fileDate: Date | null = null;\n\n if (dateMatch) {\n const [, year, month, day, hour] = dateMatch;\n fileDate = new Date(\n parseInt(year!, 10),\n parseInt(month!, 10) - 1,\n parseInt(day!, 10),\n hour ? parseInt(hour, 10) : 0,\n );\n } else if (weekMatch) {\n const [, year, week] = weekMatch;\n // Get the date of the first day of the week\n const jan4 = new Date(parseInt(year!, 10), 0, 4);\n const dayOfWeek = jan4.getDay() || 7;\n fileDate = new Date(jan4);\n fileDate.setDate(\n jan4.getDate() - dayOfWeek + 1 + (parseInt(week!, 10) - 1) * 7,\n );\n }\n\n if (fileDate && now - fileDate.getTime() > maxAgeMs) {\n const filePath = options.joinPath(directory, file);\n try {\n options.unlinkSync(filePath);\n } catch {\n // Ignore errors when deleting files\n }\n }\n }\n }\n\n if (!options.nonBlocking) {\n // Blocking mode implementation\n // deno-lint-ignore no-inner-declarations\n function flushBuffer(): void {\n if (buffer.length > 0) {\n if (shouldRotate()) {\n performRotation();\n }\n const bytes = encoder.encode(buffer);\n buffer = \"\";\n options.writeSync(fd, bytes);\n options.flushSync(fd);\n lastFlushTimestamp = Date.now();\n cleanupOldFiles();\n }\n }\n\n const sink: Sink & Disposable = (record: LogRecord) => {\n buffer += formatter(record);\n\n const shouldFlushBySize = buffer.length >= bufferSize;\n const shouldFlushByTime = flushInterval > 0 &&\n (record.timestamp - lastFlushTimestamp) >= flushInterval;\n\n if (shouldFlushBySize || shouldFlushByTime) {\n flushBuffer();\n }\n };\n\n sink[Symbol.dispose] = () => {\n flushBuffer();\n options.closeSync(fd);\n };\n\n return sink;\n }\n\n // Non-blocking mode implementation\n const asyncOptions = options as AsyncTimeRotatingFileSinkDriver<TFile>;\n let disposed = false;\n let activeFlush: Promise<void> | null = null;\n let flushTimer: ReturnType<typeof setInterval> | null = null;\n\n async function flushBuffer(): Promise<void> {\n if (buffer.length === 0) return;\n\n if (shouldRotate()) {\n performRotation();\n }\n\n const data = buffer;\n buffer = \"\";\n try {\n const bytes = encoder.encode(data);\n asyncOptions.writeSync(fd, bytes);\n await asyncOptions.flush(fd);\n lastFlushTimestamp = Date.now();\n cleanupOldFiles();\n } catch {\n // Silently ignore errors in non-blocking mode\n }\n }\n\n function scheduleFlush(): void {\n if (activeFlush || disposed) return;\n\n activeFlush = flushBuffer().finally(() => {\n activeFlush = null;\n });\n }\n\n function startFlushTimer(): void {\n if (flushTimer !== null || disposed) return;\n\n flushTimer = setInterval(() => {\n scheduleFlush();\n }, flushInterval);\n }\n\n const nonBlockingSink: Sink & AsyncDisposable = (record: LogRecord) => {\n if (disposed) return;\n buffer += formatter(record);\n\n const shouldFlushBySize = buffer.length >= bufferSize;\n const shouldFlushByTime = flushInterval > 0 &&\n (record.timestamp - lastFlushTimestamp) >= flushInterval;\n\n if (shouldFlushBySize || shouldFlushByTime) {\n scheduleFlush();\n } else if (flushTimer === null && flushInterval > 0) {\n startFlushTimer();\n }\n };\n\n nonBlockingSink[Symbol.asyncDispose] = async () => {\n disposed = true;\n if (flushTimer !== null) {\n clearInterval(flushTimer);\n flushTimer = null;\n }\n await flushBuffer();\n try {\n await asyncOptions.close(fd);\n } catch {\n // Writer might already be closed or errored\n }\n };\n\n return nonBlockingSink;\n}\n"],"mappings":";;;;;;;;AAuHA,SAAgB,WAAWA,MAAoB;CAC7C,MAAM,IAAI,IAAI,KACZ,KAAK,IAAI,KAAK,aAAa,EAAE,KAAK,UAAU,EAAE,KAAK,SAAS,CAAC;CAE/D,MAAM,SAAS,EAAE,WAAW,IAAI;AAChC,GAAE,WAAW,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AED,SAAS,kBAAwB;AAC/B,MAAI,eAAe,QAAQ,SAAU;AAErC,eAAa,YAAY,MAAM;AAC7B,kBAAe;EAChB,GAAE,cAAc;CAClB;CAED,MAAMC,kBAA0C,CAACH,WAAsB;AACrE,MAAI,SAAU;AACd,YAAU,UAAU,OAAO;EAE3B,MAAM,oBAAoB,OAAO,UAAU;EAC3C,MAAM,oBAAoB,gBAAgB,KACvC,OAAO,YAAY,sBAAuB;AAE7C,MAAI,qBAAqB,kBACvB,gBAAe;WACN,eAAe,QAAQ,gBAAgB,EAChD,kBAAiB;CAEpB;AAED,iBAAgB,OAAO,gBAAgB,YAAY;AACjD,aAAW;AACX,MAAI,eAAe,MAAM;AACvB,iBAAc,WAAW;AACzB,gBAAa;EACd;AACD,QAAM,aAAa;AACnB,MAAI;AACF,SAAM,aAAa,MAAM,GAAG;EAC7B,QAAO,CAEP;CACF;AAED,QAAO;AACR"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logtape/file",
3
- "version": "2.2.0-dev.679+7d928b73",
3
+ "version": "2.2.0-dev.683+daa1aac5",
4
4
  "description": "File sink and rotating file sink for LogTape",
5
5
  "keywords": [
6
6
  "logging",
@@ -60,7 +60,7 @@
60
60
  "dist/"
61
61
  ],
62
62
  "peerDependencies": {
63
- "@logtape/logtape": "^2.2.0-dev.679+7d928b73"
63
+ "@logtape/logtape": "^2.2.0-dev.683+daa1aac5"
64
64
  },
65
65
  "devDependencies": {
66
66
  "@alinea/suite": "^0.6.3",