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]: Cli formatter prepends "undefined" to log messages when using certain Syslog levels #2477

Open
colireg opened this issue Jun 15, 2024 · 1 comment

Comments

@colireg
Copy link

colireg commented Jun 15, 2024

🔎 Search Terms

cli, syslog, undefined

The problem

The log messages get prepended with an undefined when using certain Syslog levels (emerg, alert, crit, warning and notice) with the CLI transport formatter. Other log levels (error, info and debug) work just fine.

What version of Winston presents the issue?

^3.13.0

What version of Node are you using?

v21.7.3

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

No response

Minimum Working Example

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

const logger = createLogger({
    levels: config.syslog.levels,
    transports: [
        new transports.Console({
            format: format.cli()
        })
    ]
})

logger.emerg("Hello World!");
logger.alert("Hello World!");
logger.crit("Hello World!");
logger.warning("Hello World!");
logger.notice("Hello World!");

Additional information

The output is

emerg:undefinedHello World!
alert:undefinedHello World!
crit:undefinedHello World!
warning:undefinedHello World!
notice:undefinedHello World!
@JoshuaWLindsay
Copy link

Looks like invoking the cli method without arguments worked in winston < 3.0.0. Take a look at https://github.com/winstonjs/logform?tab=readme-ov-file#cli and see if that helps.

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

No branches or pull requests

2 participants