Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: stack gets printed regardless of format.errors #342

Open
fauxbytes opened this issue Feb 14, 2025 · 0 comments
Open

[Bug]: stack gets printed regardless of format.errors #342

fauxbytes opened this issue Feb 14, 2025 · 0 comments

Comments

@fauxbytes
Copy link

The problem

Configuring format.errors doesn't seem to have any effect. The attached MWE instantiates 3 loggers with different configuration. All seem to result in the same behavior (which is: append error message to log message, and print the stack).

What version of Logform presents the issue?

2.7.0

What version of Node are you using?

v20.18.3

If this is a TypeScript issue, what version of TypeScript are you using?

5.6.3

If this worked in a previous version of Logform, which was it?

No response

Minimum Working Example

import winston, { createLogger, format } from "winston";

const throwError = () => {throw new Error('** error message **')};
const foo = () => throwError();

const someFormat = format.json(); //or prettyPrint. or simple
const withErrors = format.combine(
  someFormat,
  format.errors({stack: true}),
);
const withErrorsNoStack = format.combine(
  someFormat,
  format.errors({stack: false}),
);

const transports = [new winston.transports.Console()];

try {
  foo();
} catch (e) {
  createLogger({format: withErrors, transports}).error('logger with errors(stack:true) :', e);
  createLogger({format: withErrorsNoStack, transports}).error('logger with errors(stack:false) :', e);
  createLogger({format: someFormat, transports}).error('logger w/o format.errors:', e);
}

Additional information

No response

🔎 Search Terms

stack error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant