[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.

feat: CJS package

* Fix pino-pretty import so it can be used by both cjs/esm
* Output cjs package with tshy

FoxxMD (Mar 8, 2024, 2:02 PM EST) 74cd6084 7c4c0b46

+18 -6
+13 -2
package.json
··· 30 30 "./factory": "./src/factory.js" 31 31 }, 32 32 "dialects": [ 33 - "esm" 33 + "esm", 34 + "commonjs" 34 35 ] 35 36 }, 36 37 "devDependencies": { ··· 77 78 "import": { 78 79 "types": "./dist/esm/index.d.ts", 79 80 "default": "./dist/esm/index.js" 81 + }, 82 + "require": { 83 + "types": "./dist/commonjs/index.d.ts", 84 + "default": "./dist/commonjs/index.js" 80 85 } 81 86 }, 82 87 "./factory": { 83 88 "import": { 84 89 "types": "./dist/esm/factory.d.ts", 85 90 "default": "./dist/esm/factory.js" 91 + }, 92 + "require": { 93 + "types": "./dist/commonjs/factory.d.ts", 94 + "default": "./dist/commonjs/factory.js" 86 95 } 87 96 } 88 - } 97 + }, 98 + "main": "./dist/commonjs/index.js", 99 + "types": "./dist/commonjs/index.d.ts" 89 100 }
+5 -4
src/destinations.ts
··· 6 6 FileDestination, 7 7 } from "./types.js"; 8 8 import {DestinationStream, pino, destination} from "pino"; 9 - import prettyDef, {PrettyOptions} from "pino-pretty"; 9 + import {build} from "pino-pretty" 10 10 import {prettyConsole, prettyFile} from "./pretty.js"; 11 11 import {fileOrDirectoryIsWriteable} from "./util.js"; 12 12 import path from "path"; 13 13 import {ErrorWithCause} from "pony-cause"; 14 14 15 15 const pRoll = pinoRoll as unknown as typeof pinoRoll.default; 16 + 16 17 /** 17 18 * Creates a `LogLevelStreamEntry` stream that writes to a rolling file at or above the minimum `level` 18 19 * */ ··· 72 73 73 74 return { 74 75 level: level, 75 - stream: prettyDef.default({...prettyFile, ...rest, destination: rollingDest}) 76 + stream: build({...prettyFile, ...rest, destination: rollingDest}) 76 77 }; 77 78 } 78 79 ··· 93 94 94 95 return { 95 96 level: level, 96 - stream: prettyDef.default({...prettyFile, ...rest, destination: dest}) 97 + stream: build({...prettyFile, ...rest, destination: dest}) 97 98 }; 98 99 } catch (e: any) { 99 100 throw new ErrorWithCause<Error>('WILL NOT write to file due to an error while trying to access the specified directory', {cause: e as Error}); ··· 108 109 export const buildDestinationStream = (level: LogLevel, options: StreamDestination): LogLevelStreamEntry => { 109 110 return { 110 111 level: level, 111 - stream: prettyDef.default({...prettyConsole, ...options}) 112 + stream: build({...prettyConsole, ...options}) 112 113 } 113 114 } 114 115