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.

Debug through logger's debug function

See original GitHub issue

Pardon me if this has already been answered. I know “debug” is not a logger and I respect that. I do not want to log with debug, I’d like debug to output in my logs instead. 😃 Specifically I’d like all third party modules using the ubiquitous “debug” to log through Winston’s debug function. It’s a matter of consistency turning log levels on/off dynamically. Is it possible?

I’ve tried to leverage node’s module caching in this way:

var Debug = require('debug');
var Logger = require('winston');
Debug.log = Logger.debug;

var mod = require('module_using_debug');

It’s not working… 😦

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:2
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
bragmacommented, Jan 12, 2016

After using it for a while, I’d say it’s not a perfect solution. It has at least 2 problems:

  1. Due to the way caching works, you have no guarantee that 3rd party modules will use the winston/debug instance you configured. If they don’t, the solution won’t work. Since even a minor version change is a different instance of a module, it does not work very often.
  2. For this solution to work, you have to enable all debug messages, then rely on Winston to disable/enable logging. This for sure has an overhead, since debug does not know about this “trick” and will format and emit all messages, Winston has to do some processing on them and finally ignore them. Considering that debug is often used for tracing code, it may be a lot of messages being uselessly processed and then thrown away.
0reactions
rbriankcommented, Dec 7, 2017

Did this happen? Having trouble finding it anywhere in the docs for 3.1

Read more comments on GitHub >

github_iconTop Results From Across the Web

Difference between logger.info and logger.debug
INFO is used to log the information your program is working as expected. · DEBUG is used to find the reason in case...
Read more >
How To Use Logging in Python 3 | DigitalOcean
Debugging is an important step of any software development project. The logging module is part of the standard Python library, provides tracking ...
Read more >
logger.debug function - RDocumentation
After initializing the level-specific log files with logger.setup(...) , this function will generate DEBUG level log statements.
Read more >
How to add a DEBUG mode for your Python Logging Mid-Run
To initiate “debug_mode” we will have a function in module_1.py which initiates debug level in the root logger. Step 1: File creations. Create...
Read more >
logging — Logging facility for Python — Python 3.11.1 ...
Logs a message with level DEBUG on this logger. ... This can be used in logging helpers so that the function name, filename...
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