Skip to main content
zerotal

Documentation


Documentation / zerotal / logger / DailyChannel

Class: DailyChannel

Defined in: packages/core/src/logger/channels/DailyChannel.ts:26

Appends entries as JSON lines to a date-rotated file, one file per day named YYYY-MM-DD.log (derived from the entry's timestamp) inside a directory.

Writes go through a StorageDriver, so the log trail uses the same file API as uploads and the media library rather than a second, private way of putting bytes on disk — and inherits its path-traversal guard for free.

When a retention window (days) is given, files whose modification time is older than the cutoff are pruned — checked at most once every 24 hours, in the background, and only on write. The directory is created on demand.

Example

// config/logging.ts — keep 14 days of daily files under ./storage/logs
file: { path: "./storage/logs", days: 14 },

Implements

Constructors

Constructor

new DailyChannel(_dir, _days?, disk?): DailyChannel

Defined in: packages/core/src/logger/channels/DailyChannel.ts:37

Parameters

_dir

string

Directory that holds the per-day log files.

_days?

number

Retention window in days; older files are pruned. Omit to keep files forever.

disk?

StorageDriver

Driver to write through. Defaults to a LocalDriver rooted at _dir. Pass one to send the trail somewhere else — it must support append, which rules out object stores.

Returns

DailyChannel

Methods

write()

write(entry): Promise<void>

Defined in: packages/core/src/logger/channels/DailyChannel.ts:45

Parameters

entry

LogEntry

Returns

Promise<void>

Implementation of

LogChannel.write