@tejika/log
v0.4.2
Published
Local log files: rotating file sinks and logtape configuration
Maintainers
Readme
@tejika/log
Local log files for CLI tools and daemons: rotating file sinks and a logtape
Config builder. The host application supplies @logtape/logtape (a peer
dependency) and applies the config with logtape's configure() (or a host wrapper such as @sozai/log's setup()).
pnpm add @tejika/log @logtape/logtapecreateFileSink— a rotating log-fileSinkfor an app, written undergetLogDir(app)by default. Daily or hourly rotation,text(.log) orjsonLines(.jsonl) format, and retention-based pruning.createFileLogConfig— build a whole logtapeConfigfrom a list of file targets (each with its own category and level), plus an optional console sink. The builder is pure: it never touches logtape's process-global state.followLog— tail a log file until anAbortSignalaborts, re-reading from the start after truncation.
import { configure } from '@logtape/logtape'
import { createFileLogConfig } from '@tejika/log'
await configure(
createFileLogConfig({
app: 'myapp',
files: [{ name: 'app', category: ['myapp'], level: 'info' }],
console: 'error',
}),
)Building a config is not free — every file target creates its directory and opens a descriptor — so build one only when it is going to be used.
