pygx.instrument.logging¶
Logging for PyGX.
logging
¶
Logging for PyGX.
This module allows PyGX to use an externally created logger for logging PyGX events without introducing library dependencies in PyGX.
register_frame_to_skip
¶
Registers the source of the given method to be skipped when logging.
Only has an effect when the current logger's class supports frame
skipping (i.e. exposes a register_frame_to_skip method).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
method
|
Callable[..., Any] | list[Callable[..., Any]]
|
The method to skip. Can be a single method or a list of methods. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the method is registered to skip; False if the current logger |
bool
|
class does not support frame skipping. |
Raises:
| Type | Description |
|---|---|
TypeError
|
The source file of the method cannot be inspected. |
Source code in pygx/instrument/_logging.py
set_logger
¶
Sets current logger.
Source code in pygx/instrument/_logging.py
get_logger
¶
debug
¶
Logs debug message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
msg
|
str
|
Message with possible format string. |
required |
*args
|
Any
|
Values for variables in the format string. |
()
|
**kwargs
|
Any
|
Keyword arguments for the logger. |
{}
|
Source code in pygx/instrument/_logging.py
info
¶
Logs info message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
msg
|
str
|
Message with possible format string. |
required |
*args
|
Any
|
Values for variables in the format string. |
()
|
**kwargs
|
Any
|
Keyword arguments for the logger. |
{}
|
Source code in pygx/instrument/_logging.py
warning
¶
Logs warning message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
msg
|
str
|
Message with possible format string. |
required |
*args
|
Any
|
Values for variables in the format string. |
()
|
**kwargs
|
Any
|
Keyword arguments for the logger. |
{}
|
Source code in pygx/instrument/_logging.py
error
¶
Logs error message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
msg
|
str
|
Message with possible format string. |
required |
*args
|
Any
|
Values for variables in the format string. |
()
|
**kwargs
|
Any
|
Keyword arguments for the logger. |
{}
|
Source code in pygx/instrument/_logging.py
critical
¶
Logs critical message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
msg
|
str
|
Message with possible format string. |
required |
*args
|
Any
|
Values for variables in the format string. |
()
|
**kwargs
|
Any
|
Keyword arguments for the logger. |
{}
|
Source code in pygx/instrument/_logging.py
use_stream
¶
use_stream(
stream: Any,
level: int = INFO,
name: str = "custom",
fmt: str = "{levelname:8} | {asctime} | {message}",
datefmt: str = "%Y-%m-%d %H:%M:%S",
) -> Logger
Uses the given stream for logging and installs it as current logger.
Source code in pygx/instrument/_logging.py
use_stdout
¶
use_stdout(
level: int = INFO,
fmt: str = "{levelname:8} | {asctime} | {message}",
datefmt: str = "%Y-%m-%d %H:%M:%S",
) -> Logger
Uses stdout for logging and installs it as current logger.
Source code in pygx/instrument/_logging.py
redirect_stream
¶
redirect_stream(
stream: Any,
level: int = INFO,
name: str = "custom",
fmt: str = "{levelname:8} | {asctime} | {message}",
datefmt: str = "%Y-%m-%d %H:%M:%S",
) -> Iterator[Logger]
Context manager to log to the given stream within a scope.
Installs a stream-backed logger as the current logger for the duration of the scope, restoring the previous logger on exit.
Source code in pygx/instrument/_logging.py
options: show_root_heading: false show_root_toc_entry: false members_order: source heading_level: 2