logging_tools
log_level_by_name = log_level module-attribute ¶
LogLevel ¶
Bases: Enum
Source code in src/recnexteval/utils/logging_tools.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | |
CRITICAL = logging.CRITICAL class-attribute instance-attribute ¶
ERROR = logging.ERROR class-attribute instance-attribute ¶
WARNING = logging.WARNING class-attribute instance-attribute ¶
INFO = logging.INFO class-attribute instance-attribute ¶
DEBUG = logging.DEBUG class-attribute instance-attribute ¶
NOTSET = logging.NOTSET class-attribute instance-attribute ¶
from_string(level) classmethod ¶
Return a LogLevel member from a case-insensitive string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
level | str | Name of the log level (case-insensitive). | required |
Returns:
| Type | Description |
|---|---|
LogLevel | The corresponding :class: |
Source code in src/recnexteval/utils/logging_tools.py
24 25 26 27 28 29 30 31 32 33 34 | |
log_level(level) ¶
Change the logging level for the root logger.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
level | int | str | LogLevel | The logging level to set. May be a :class: | required |
Returns:
| Type | Description |
|---|---|
None | None |
Source code in src/recnexteval/utils/logging_tools.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | |
suppress_warnings() ¶
Suppress all Python warnings.
This will disable warning output by filtering all warnings and disabling logging's capture of warnings.
Returns:
| Type | Description |
|---|---|
None | None |
Source code in src/recnexteval/utils/logging_tools.py
61 62 63 64 65 66 67 68 69 70 71 | |
enable_warnings() ¶
Enable Python warnings (reset to default behavior).
This re-enables warning capture and resets any filters previously set.
Returns:
| Type | Description |
|---|---|
None | None |
Source code in src/recnexteval/utils/logging_tools.py
74 75 76 77 78 79 80 81 82 83 | |
suppress_specific_warnings(category) ¶
Suppress warnings of a specific category.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
category | type[Warning] | Warning class/type to suppress (for example, :class: | required |
Returns:
| Type | Description |
|---|---|
None | None |
Source code in src/recnexteval/utils/logging_tools.py
86 87 88 89 90 91 92 93 94 95 | |
warnings_suppressed() ¶
Context manager that temporarily suppresses all warnings.
Yields:
| Name | Type | Description |
|---|---|---|
None | Generator | Warnings are suppressed inside the context block. |
Source code in src/recnexteval/utils/logging_tools.py
98 99 100 101 102 103 104 105 106 107 108 109 110 111 | |
prepare_logger(log_config_filename) ¶
Prepare and configure logging from a YAML file.
This function locates or creates a logging configuration YAML file using :func:recnexteval.utils.yaml_tool.create_config_yaml, ensures the directory for the configured log file exists, writes an ASCII art header to the log file, and configures the Python logging system using :func:logging.config.dictConfig.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
log_config_filename | str | Name of the logging configuration YAML file. | required |
Returns:
| Name | Type | Description |
|---|---|---|
dict | dict | The parsed logging configuration dictionary. |
Raises:
| Type | Description |
|---|---|
FileNotFoundError | If the resolved YAML configuration file cannot be found. |
ValueError | If there is an error parsing the YAML content. |
Source code in src/recnexteval/utils/logging_tools.py
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | |