From 341357c0c8eb6d7525ccc7effb80e01cd41b0d73 Mon Sep 17 00:00:00 2001 From: FoxxMD Date: Fri, 1 Mar 2024 15:33:17 -0500 Subject: [PATCH] fix: Fix sync log destination and specify out/err destinations --- src/destinations.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/destinations.ts b/src/destinations.ts index cb4d9ea..4877544 100644 --- a/src/destinations.ts +++ b/src/destinations.ts @@ -1,6 +1,6 @@ import pinoRoll from 'pino-roll'; import {LogLevelStreamEntry, LogLevel, LogOptions, StreamDestination, FileDestination} from "./types.js"; -import {DestinationStream, pino} from "pino"; +import {DestinationStream, pino, destination} from "pino"; import prettyDef, {PrettyOptions} from "pino-pretty"; import {prettyConsole, prettyFile} from "./pretty.js"; import {fileOrDirectoryIsWriteable} from "./util.js"; @@ -45,7 +45,7 @@ export const buildDestinationFile = (level: LogLevel | false, options: FileDesti try { fileOrDirectoryIsWriteable(logPath); - const dest = pino.destination({dest: path, sync: false}) + const dest = destination({dest: logPath, mkdir: true, sync: false}) return { level: level, @@ -64,15 +64,16 @@ export const buildDestinationStream = (level: LogLevel, options: StreamDestinati } export const buildDestinationStdout = (level: LogLevel, options: Omit = {}): LogLevelStreamEntry => { + const opts = {...prettyConsole, ...options, destination: destination({dest: 1, sync: true})} return { level: level, - stream: prettyDef.default({...prettyConsole, ...options, destination: 1}) + stream: prettyDef.default(opts) } } export const buildDestinationStderr = (level: LogLevel, options: Omit = {}): LogLevelStreamEntry => { return { level: level, - stream: prettyDef.default({...prettyConsole, ...options, destination: 2}) + stream: prettyDef.default({...prettyConsole, ...options, destination: destination({dest: 2, sync: true})}) } }