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
···11import {childLogger, loggerApp, loggerDebug} from '../src/index.js'
22-import {ErrorWithCause} from "pony-cause";
32import process from "process";
43import path from 'path';
54···2423logger.debug({myProp: 'a string', nested: {anotherProps: ['val1', 'val2'], boolProp: true}}, 'Test');
25242625const er = new Error('A configuration error occurred');
2727-const causeErr = new ErrorWithCause('Service C did not start', {cause: er});
2626+const causeErr = new Error('Service C did not start', {cause: er});
2827logger.error(causeErr);
29283029logger.verbose('(1) service failed to start but is non-essential...continuing startup')
+1-2
example/runkit.js
···11const logging = require('@foxxmd/logging');
22-const ec = require('pony-cause');
3243const {childLogger, loggerApp, loggerDebug} = logging;
54const {ErrorWithCause} = ec;
···2524logger.debug({myProp: 'a string', nested: {anotherProps: ['val1', 'val2'], boolProp: true}}, 'Test');
26252726const er = new Error('A configuration error occurred');
2828-const causeErr = new ErrorWithCause('Service C did not start', {cause: er});
2727+const causeErr = new Error('Service C did not start', {cause: er});
2928logger.error(causeErr);
30293130logger.verbose('(1) service failed to start but is non-essential...continuing startup')
···1010import {PRETTY_OPTS_CONSOLE, PRETTY_OPTS_FILE, prettyOptsConsoleFactory, prettyOptsFileFactory} from "./pretty.js";
1111import {fileOrDirectoryIsWriteable} from "./util.js";
1212import path from "path";
1313-import {ErrorWithCause} from "pony-cause";
1313+14141515const pRoll = pinoRoll as unknown as typeof pinoRoll.default;
1616···3838 try {
3939 fileOrDirectoryIsWriteable(testPath);
4040 } catch (e: any) {
4141- 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});
4141+ throw new Error('Cannot write logs to rotating file due to an error while trying to access the specified logging directory', {cause: e});
4242 }
43434444 const pInfo = path.parse(testPath);
···9797 stream: build({...prettyOptsFileFactory(rest), ...rest, destination: dest})
9898 };
9999 } catch (e: any) {
100100- throw new ErrorWithCause<Error>('WILL NOT write to file due to an error while trying to access the specified directory', {cause: e as Error});
100100+ throw new Error('WILL NOT write to file due to an error while trying to access the specified directory', {cause: e});
101101 }
102102}
103103
+1-2
src/types.ts
···11import {DestinationStream, Logger as PinoLogger, LoggerOptions, StreamEntry, Level} from 'pino';
22-import {ErrorWithCause} from "pony-cause";
32import {PrettyOptions} from "pino-pretty";
43import {MarkRequired} from "ts-essentials";
54···7574 pid: number
7675 hostname: string
7776 labels: any[]
7878- msg: string | Error | ErrorWithCause
7777+ msg: string | Error
7978}
80798180export interface PinoRollOptions {
+2-3
src/util.ts
···11import pathUtil from "path";
22import {accessSync, constants} from "fs";
33-import {ErrorWithCause} from "pony-cause";
43import process from "process";
5465export const fileOrDirectoryIsWriteable = (location: string) => {
···3635 // also can't access directory :(
3736 throw new Error(`No ${isDir ? 'directory' : 'file'} exists at ${location} and application does not have permission to write to the parent directory`);
3837 } else {
3939- 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});
3838+ 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});
4039 }
4140 } else if (code === 'EACCES') {
4241 throw new Error(`${isDir ? 'Directory' : 'File'} exists at ${location} but application does not have permission to write to it.`);
4342 } else {
4444- throw new ErrorWithCause(`${isDir ? 'Directory' : 'File'} exists at ${location} but application is unable to access it due to a system error`, {cause: err});
4343+ throw new Error(`${isDir ? 'Directory' : 'File'} exists at ${location} but application is unable to access it due to a system error`, {cause: err});
4544 }
4645 }
4746}