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

Error formatted by Console transport is undefined #224

Open
davelowndes opened this issue Jun 9, 2024 · 0 comments
Open

Error formatted by Console transport is undefined #224

davelowndes opened this issue Jun 9, 2024 · 0 comments

Comments

@davelowndes
Copy link

Environment:
winston 3.13.0
Windows 11
node v20.5.1

If I use format inside new winston.transports.Console() the Error is undefined:

import winston from 'winston'

const logger = winston.createLogger({
    transports: [new winston.transports.Console()],
    format: winston.format.printf((info) => {
        return `${info.level}: ${info.message}`
    })
})

const logger2 = winston.createLogger({
    transports: [new winston.transports.Console({
        format: winston.format.printf((info) => {
            return `${info.level}: ${info.message}`
        })
    }
    )],
})


logger.info('test')
logger2.info('test')

try {
    throw new Error('oh no!')
} catch (err) {
    logger.error(err)
    logger2.error(err)
}

Output:

info: test
info: test
error: oh no!
error: undefined
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