Logger module¶
Reference to the logger.py module.
logger
¶
Logger module that writes to stderr.
This module provides utilities for redirecting standard output to standard error and for writing log messages directly to stderr.
| FUNCTION | DESCRIPTION |
|---|---|
redirect_stdout |
Redirect all messages written to stdout to stderr. |
reset_stdout |
Reset stdout to its original value. |
log |
Log a message to stderr. |
redirect_stdout
¶
Redirect all messages written to stdout to stderr.
You can import the redirect_stdout function directly from nextmv:
This function captures the current sys.stdout and replaces it with sys.stderr.
When redirection is no longer needed, call reset_stdout() to restore the
original stdout.
Examples:
>>> redirect_stdout()
>>> print("This will go to stderr")
>>> reset_stdout()
>>> print("This will go to stdout")
Source code in nextmv-py/nextmv/nextmv/logger.py
reset_stdout
¶
Reset stdout to its original value.
You can import the reset_stdout function directly from nextmv:
This function should always be called after redirect_stdout() to avoid
unexpected behavior. It restores the original stdout that was captured
during redirection.
Examples:
>>> redirect_stdout()
>>> print("This will go to stderr")
>>> reset_stdout()
>>> print("This will go to stdout")
Source code in nextmv-py/nextmv/nextmv/logger.py
log
¶
Log a message to stderr.
You can import the log function directly from nextmv:
| PARAMETER | DESCRIPTION |
|---|---|
|
The message to log.
TYPE:
|
Examples: