[READ-ONLY] Mirror of https://github.com/FoxxMD/logging. A typed, opinionated, batteries-included, Pino-based logging solution for backend TS/JS projects foxxmd.github.io/logging
child-logger logging logging-library nodejs pinojs typescript-library
0

Configure Feed

Select the types of activity you want to include in your feed.

fix: Fix sync log destination and specify out/err destinations

FoxxMD (Mar 1, 2024, 3:33 PM EST) 341357c0 4062693b

+5 -4
+5 -4
src/destinations.ts
··· 1 1 import pinoRoll from 'pino-roll'; 2 2 import {LogLevelStreamEntry, LogLevel, LogOptions, StreamDestination, FileDestination} from "./types.js"; 3 - import {DestinationStream, pino} from "pino"; 3 + import {DestinationStream, pino, destination} from "pino"; 4 4 import prettyDef, {PrettyOptions} from "pino-pretty"; 5 5 import {prettyConsole, prettyFile} from "./pretty.js"; 6 6 import {fileOrDirectoryIsWriteable} from "./util.js"; ··· 45 45 46 46 try { 47 47 fileOrDirectoryIsWriteable(logPath); 48 - const dest = pino.destination({dest: path, sync: false}) 48 + const dest = destination({dest: logPath, mkdir: true, sync: false}) 49 49 50 50 return { 51 51 level: level, ··· 64 64 } 65 65 66 66 export const buildDestinationStdout = (level: LogLevel, options: Omit<StreamDestination, 'destination'> = {}): LogLevelStreamEntry => { 67 + const opts = {...prettyConsole, ...options, destination: destination({dest: 1, sync: true})} 67 68 return { 68 69 level: level, 69 - stream: prettyDef.default({...prettyConsole, ...options, destination: 1}) 70 + stream: prettyDef.default(opts) 70 71 } 71 72 } 72 73 73 74 export const buildDestinationStderr = (level: LogLevel, options: Omit<StreamDestination, 'destination'> = {}): LogLevelStreamEntry => { 74 75 return { 75 76 level: level, 76 - stream: prettyDef.default({...prettyConsole, ...options, destination: 2}) 77 + stream: prettyDef.default({...prettyConsole, ...options, destination: destination({dest: 2, sync: true})}) 77 78 } 78 79 }