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

chore: Remove pony-cause

Didn't realize Error Cause (https://github.com/tc39/proposal-error-cause) had been finalized and was included in es2022! Hooray for one less dependency

FoxxMD (Mar 11, 2024, 3:22 PM EDT) c17163b2 0d03411d

+13 -27
+1 -2
example/kitchenSink.ts
··· 1 1 import {childLogger, loggerApp, loggerDebug} from '../src/index.js' 2 - import {ErrorWithCause} from "pony-cause"; 3 2 import process from "process"; 4 3 import path from 'path'; 5 4 ··· 24 23 logger.debug({myProp: 'a string', nested: {anotherProps: ['val1', 'val2'], boolProp: true}}, 'Test'); 25 24 26 25 const er = new Error('A configuration error occurred'); 27 - const causeErr = new ErrorWithCause('Service C did not start', {cause: er}); 26 + const causeErr = new Error('Service C did not start', {cause: er}); 28 27 logger.error(causeErr); 29 28 30 29 logger.verbose('(1) service failed to start but is non-essential...continuing startup')
+1 -2
example/runkit.js
··· 1 1 const logging = require('@foxxmd/logging'); 2 - const ec = require('pony-cause'); 3 2 4 3 const {childLogger, loggerApp, loggerDebug} = logging; 5 4 const {ErrorWithCause} = ec; ··· 25 24 logger.debug({myProp: 'a string', nested: {anotherProps: ['val1', 'val2'], boolProp: true}}, 'Test'); 26 25 27 26 const er = new Error('A configuration error occurred'); 28 - const causeErr = new ErrorWithCause('Service C did not start', {cause: er}); 27 + const causeErr = new Error('Service C did not start', {cause: er}); 29 28 logger.error(causeErr); 30 29 31 30 logger.verbose('(1) service failed to start but is non-essential...continuing startup')
+3 -12
package-lock.json
··· 1 1 { 2 2 "name": "@foxxmd/logging", 3 - "version": "0.1.4", 3 + "version": "0.1.5", 4 4 "lockfileVersion": 3, 5 5 "requires": true, 6 6 "packages": { 7 7 "": { 8 8 "name": "@foxxmd/logging", 9 - "version": "0.1.4", 9 + "version": "0.1.5", 10 10 "license": "MIT", 11 11 "dependencies": { 12 12 "pino": "^8.19.0", 13 13 "pino-pretty": "github:foxxmd/pino-pretty#additionalFunctionality", 14 - "pino-roll": "github:foxxmd/pino-roll#fileAsFunc", 15 - "pony-cause": "^2.1.10" 14 + "pino-roll": "github:foxxmd/pino-roll#fileAsFunc" 16 15 }, 17 16 "devDependencies": { 18 17 "@types/chai": "^4.3.0", ··· 1847 1846 }, 1848 1847 "funding": { 1849 1848 "url": "https://github.com/sponsors/isaacs" 1850 - } 1851 - }, 1852 - "node_modules/pony-cause": { 1853 - "version": "2.1.10", 1854 - "resolved": "https://registry.npmjs.org/pony-cause/-/pony-cause-2.1.10.tgz", 1855 - "integrity": "sha512-3IKLNXclQgkU++2fSi93sQ6BznFuxSLB11HdvZQ6JW/spahf/P1pAHBQEahr20rs0htZW0UDkM1HmA+nZkXKsw==", 1856 - "engines": { 1857 - "node": ">=12.0.0" 1858 1849 } 1859 1850 }, 1860 1851 "node_modules/process": {
+2 -3
package.json
··· 1 1 { 2 2 "name": "@foxxmd/logging", 3 3 "type": "module", 4 - "version": "0.1.4", 4 + "version": "0.1.5", 5 5 "repository": "https://github.com/foxxmd/logging", 6 6 "description": "A typed, opinionated, batteries-included, Pino-based logging solution for backend TS/JS projects", 7 7 "scripts": { ··· 69 69 "dependencies": { 70 70 "pino": "^8.19.0", 71 71 "pino-pretty": "github:foxxmd/pino-pretty#additionalFunctionality", 72 - "pino-roll": "github:foxxmd/pino-roll#fileAsFunc", 73 - "pony-cause": "^2.1.10" 72 + "pino-roll": "github:foxxmd/pino-roll#fileAsFunc" 74 73 }, 75 74 "overrides": { 76 75 "with-local-tmp-dir": {
+3 -3
src/destinations.ts
··· 10 10 import {PRETTY_OPTS_CONSOLE, PRETTY_OPTS_FILE, prettyOptsConsoleFactory, prettyOptsFileFactory} from "./pretty.js"; 11 11 import {fileOrDirectoryIsWriteable} from "./util.js"; 12 12 import path from "path"; 13 - import {ErrorWithCause} from "pony-cause"; 13 + 14 14 15 15 const pRoll = pinoRoll as unknown as typeof pinoRoll.default; 16 16 ··· 38 38 try { 39 39 fileOrDirectoryIsWriteable(testPath); 40 40 } catch (e: any) { 41 - throw new ErrorWithCause<Error>('Cannot write logs to rotating file due to an error while trying to access the specified logging directory', {cause: e as Error}); 41 + throw new Error('Cannot write logs to rotating file due to an error while trying to access the specified logging directory', {cause: e}); 42 42 } 43 43 44 44 const pInfo = path.parse(testPath); ··· 97 97 stream: build({...prettyOptsFileFactory(rest), ...rest, destination: dest}) 98 98 }; 99 99 } catch (e: any) { 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}); 100 + throw new Error('WILL NOT write to file due to an error while trying to access the specified directory', {cause: e}); 101 101 } 102 102 } 103 103
+1 -2
src/types.ts
··· 1 1 import {DestinationStream, Logger as PinoLogger, LoggerOptions, StreamEntry, Level} from 'pino'; 2 - import {ErrorWithCause} from "pony-cause"; 3 2 import {PrettyOptions} from "pino-pretty"; 4 3 import {MarkRequired} from "ts-essentials"; 5 4 ··· 75 74 pid: number 76 75 hostname: string 77 76 labels: any[] 78 - msg: string | Error | ErrorWithCause 77 + msg: string | Error 79 78 } 80 79 81 80 export interface PinoRollOptions {
+2 -3
src/util.ts
··· 1 1 import pathUtil from "path"; 2 2 import {accessSync, constants} from "fs"; 3 - import {ErrorWithCause} from "pony-cause"; 4 3 import process from "process"; 5 4 6 5 export const fileOrDirectoryIsWriteable = (location: string) => { ··· 36 35 // also can't access directory :( 37 36 throw new Error(`No ${isDir ? 'directory' : 'file'} exists at ${location} and application does not have permission to write to the parent directory`); 38 37 } else { 39 - throw new ErrorWithCause(`No ${isDir ? 'directory' : 'file'} exists at ${location} and application is unable to access the parent directory due to a system error`, {cause: accessError}); 38 + throw new Error(`No ${isDir ? 'directory' : 'file'} exists at ${location} and application is unable to access the parent directory due to a system error`, {cause: accessError}); 40 39 } 41 40 } else if (code === 'EACCES') { 42 41 throw new Error(`${isDir ? 'Directory' : 'File'} exists at ${location} but application does not have permission to write to it.`); 43 42 } else { 44 - throw new ErrorWithCause(`${isDir ? 'Directory' : 'File'} exists at ${location} but application is unable to access it due to a system error`, {cause: err}); 43 + throw new Error(`${isDir ? 'Directory' : 'File'} exists at ${location} but application is unable to access it due to a system error`, {cause: err}); 45 44 } 46 45 } 47 46 }