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.

Use a logger with different logging levels

See original GitHub issue

Currently, inside of the Guess.js webpack plugin there are a lot of statements in the form:

if (this._config.debug) {
  console.warn(...);
}

Instead of having this duplication of this._config.debug checks, it’d be better if we isolate the logic into a logger with different logging levels. We can either create a custom logger (no dependencies, smaller payload) or go with an existing one (code reuse).

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
mgechevcommented, Jul 29, 2019

@vprasanth looks great! Just merged the PR which introduced the logger & the initial refactoring. Feel free to replace the other console occurrences 😃

0reactions
vprasanthcommented, Jul 29, 2019

Hey, sorry for the delay, was at a cottage this weekend 😃

Anyways, I ended up adding a couple more log levels – but set the logger to DEBUG. I added the additional levels to cover error and warn. So in total there is DEBUG, INFO, WARN, ERROR, and OFF. Default for the logger is set to INFO.

I’ve so far only updated the prefetch-aot-plugin file, I noticed some other places within the guess-webpack package that use console, wasn’t sure if you wanted those updated as well. Figured I’d wait for a review then update the rest if wanted. Let me know 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Logging Levels: What They Are & How to Choose Them
A log level used for events considered to be useful during software debugging when more granular information is needed. Trace, A log level...
Read more >
How to set different levels for different python log handlers
You can set a different logging level for each logging handler but it seems you will have to set the logger's level to...
Read more >
How to Choose Levels of Logging - Section.io
Logging levels explained. The most common logging levels include FATAL, ERROR, WARN, INFO, DEBUG, TRACE, ALL, and OFF. Some of them are ...
Read more >
Understanding logging levels - IBM
Each log message has an associated log level that gives a rough guide to the importance and urgency of the message. Each level...
Read more >
Python Logging Levels Explained - LogicMonitor
The logger can then be used to send out simple formatted messages at different logging levels (such as DEBUG, INFO, ERROR), which the...
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