question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Winston 3 console transport (and base transport) not working in the browser

See original GitHub issue

Please tell us about your environment:

  • winston version?
    • winston@2
    • winston@3
  • node -v outputs: 8.11.1
  • Operating System? macOS
  • Language? JS, ES6+

What is the problem?

Am I right in thinking that Winston 3 is aiming to be compatible in Node and the browser? If so, the browser throws up on setImmediate, as it’s a native Node thing. Currently, setImmediate is recommended to use this within new transports, so I can’t quite see how this can work.

To re-produce:

Init somewhere:

import { createLogger, transports } from 'winston'

const consoleTransport = new transports.Console({ handleExceptions: true })

const logger = createLogger({
  transports: [ consoleTransport ]
})

export default logger

Import and use somewhere in client-side code:

import logger from './logger'
logger.info('message for the browser console')

What do you expect to happen instead?

The browser console to log out the message

Sorry if I’m missing something here!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:6
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

6reactions
jpsearcommented, Oct 2, 2018

@sneko I just installed setImmediate through npm: https://github.com/YuzuJS/setImmediate, then included it in my webpack bundle by importing it:

import 'setimmediate'

Then it’s patched and available globally, on the window object

3reactions
BeauBouchardcommented, Jul 22, 2021

+1 on this issue in “winston”: “3.3.3”

Read more comments on GitHub >

github_iconTop Results From Across the Web

A Complete Guide to Winston Logging in Node.js - Better Stack
The following transport options are available in Winston by default: Console: output logs to the Node.js console. File: store log messages to one...
Read more >
Node.js Logging with Winston - Reflectoring
We've been using the Console transport by default to display log messages. Let's look at how to use the File option. Storing Winston...
Read more >
Can Winston Logger be used on the front-end for logging?
Yeah it is possible, however default transport for browser is very limited.
Read more >
Logging with Winston and Node.js - Section.io
Winston allows you to implement multiple logging transports, i.e., a log can be recorded to a file, console, or database. The Logger ...
Read more >
winston-transport-browserconsole - npm package - Snyk
BrowserConsole transport for winston logger. ... Latest version published 3 years ago. License: MIT ... security. No known security issues. popularity.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found