Logging¶
soundscapy.sspylogging
¶
Logging configuration for Soundscapy.
This module provides simple functions to configure logging for both users and developers. By default, Soundscapy logging is disabled to avoid unwanted output. Users can enable logging with the setup_logging function.
| FUNCTION | DESCRIPTION |
|---|---|
setup_logging |
Set up logging for Soundscapy with sensible defaults. |
enable_debug |
Quickly enable DEBUG level logging to console. |
disable_logging |
Disable all Soundscapy logging. |
get_logger |
Get the Soundscapy logger instance. |
is_notebook |
Check if code is running in Jupyter notebook. |
setup_logging
¶
setup_logging(
level: str = "INFO",
log_file: str | Path | None = None,
format_level: str = "basic",
) -> None
Set up logging for Soundscapy with sensible defaults.
| PARAMETER | DESCRIPTION |
|---|---|
level
|
Logging level for console output. Options: "DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"
TYPE:
|
log_file
|
Path to a log file. If provided, all messages (including DEBUG) will be logged to this file. |
format_level
|
Format complexity level. Options:
TYPE:
|
Examples:
>>> from soundscapy import setup_logging
>>> # Basic usage - show INFO level and above in console
>>> setup_logging()
>>>
>>> # Enable DEBUG level and log to file
>>> setup_logging(level="DEBUG", log_file="soundscapy.log")
>>>
>>> # Use detailed format for debugging
>>> setup_logging(level="DEBUG", format_level="detailed")
Source code in src/soundscapy/sspylogging.py
enable_debug
¶
Quickly enable DEBUG level logging to console.
This is a convenience function for debugging during interactive sessions.
Examples:
>>> from soundscapy import enable_debug
>>> enable_debug()
>>> # Now all debug messages will be shown
Source code in src/soundscapy/sspylogging.py
disable_logging
¶
Disable all Soundscapy logging.
Examples:
>>> from soundscapy import disable_logging
>>> disable_logging()
>>> # No more logging messages will be shown
Source code in src/soundscapy/sspylogging.py
get_logger
¶
Get the Soundscapy logger instance.
Returns the loguru logger configured for Soundscapy. This is mainly for advanced users who want to configure logging themselves.
| RETURNS | DESCRIPTION |
|---|---|
Logger
|
The loguru logger instance |
Examples:
>>> from soundscapy import get_logger
>>> logger = get_logger()
>>> logger.debug("Custom debug message")
Source code in src/soundscapy/sspylogging.py
is_notebook
¶
Check if code is running in Jupyter notebook.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if running in a Jupyter notebook, False otherwise |