UNPKG

@papabravocorp/pluggable-logger

Version:

A pluggable logger for Node.js that writes structured logs to local file systems, Azure ADLS, or custom storage backends.

19 lines (18 loc) 680 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.LocalFsProvider = void 0; const promises_1 = require("fs/promises"); const path_1 = require("path"); class LocalFsProvider { constructor(baseDir) { this.baseDir = baseDir; } async write(entry) { const date = entry.timestamp.slice(0, 10); const filePath = (0, path_1.join)(this.baseDir, `${date}.log`); await (0, promises_1.mkdir)((0, path_1.dirname)(filePath), { recursive: true }); const line = JSON.stringify(entry) + '\n'; await (0, promises_1.appendFile)(filePath, line, 'utf8'); } } exports.LocalFsProvider = LocalFsProvider;