Logging¶
๐ค Diffusers has a centralized logging system to easily manage the verbosity of the library. The default verbosity is set to WARNING
.
To change the verbosity level, use one of the direct setters. For instance, to change the verbosity to the INFO
level.
import mindone.diffusers
mindone.diffusers.logging.set_verbosity_info()
You can also use the environment variable DIFFUSERS_VERBOSITY
to override the default verbosity. You can set it
to one of the following: debug
, info
, warning
, error
, critical
. For example:
DIFFUSERS_VERBOSITY=error ./myprogram.py
Additionally, some warnings
can be disabled by setting the environment variable
DIFFUSERS_NO_ADVISORY_WARNINGS
to a true value, like 1
. This disables any warning logged by
[logger.warning_advice
]. For example:
DIFFUSERS_NO_ADVISORY_WARNINGS=1 ./myprogram.py
Here is an example of how to use the same logger as the library in your own module or script:
from mindone.diffusers.utils import logging
logging.set_verbosity_info()
logger = logging.get_logger("diffusers")
logger.info("INFO")
logger.warning("WARN")
All methods of the logging module are documented below. The main methods are
get_verbosity
to get the current level of verbosity in the logger and
set_verbosity
to set the verbosity to the level of your choice.
In order from the least verbose to the most verbose:
Method | Integer value | Description |
---|---|---|
diffusers.logging.CRITICAL or diffusers.logging.FATAL |
50 | only report the most critical errors |
diffusers.logging.ERROR |
40 | only report errors |
diffusers.logging.WARNING or diffusers.logging.WARN |
30 | only report errors and warnings (default) |
diffusers.logging.INFO |
20 | only report errors, warnings, and basic information |
diffusers.logging.DEBUG |
10 | report all information |
By default, tqdm
progress bars are displayed during model download. disable_progress_bar
and enable_progress_bar
are used to enable or disable this behavior.
Base setters¶
mindone.diffusers.utils.logging.set_verbosity_error()
¶
Set the verbosity to the ERROR
level.
Source code in mindone/diffusers/utils/logging.py
170 171 172 |
|
mindone.diffusers.utils.logging.set_verbosity_warning()
¶
Set the verbosity to the WARNING
level.
Source code in mindone/diffusers/utils/logging.py
160 161 162 |
|
mindone.diffusers.utils.logging.set_verbosity_info()
¶
Set the verbosity to the INFO
level.
Source code in mindone/diffusers/utils/logging.py
155 156 157 |
|
mindone.diffusers.utils.logging.set_verbosity_debug()
¶
Set the verbosity to the DEBUG
level.
Source code in mindone/diffusers/utils/logging.py
165 166 167 |
|
Other functions¶
mindone.diffusers.utils.logging.get_verbosity()
¶
Return the current level for the ๐ค Diffusers' root logger as an int
.
RETURNS | DESCRIPTION |
---|---|
int
|
|
Source code in mindone/diffusers/utils/logging.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
|
mindone.diffusers.utils.logging.set_verbosity(verbosity)
¶
Set the verbosity level for the ๐ค Diffusers' root logger.
PARAMETER | DESCRIPTION |
---|---|
verbosity |
Logging level which can be one of:
TYPE:
|
Source code in mindone/diffusers/utils/logging.py
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
|
mindone.diffusers.utils.logging.get_logger(name=None)
¶
Return a logger with the specified name.
This function is not supposed to be directly accessed unless you are writing a custom diffusers module.
Source code in mindone/diffusers/utils/logging.py
102 103 104 105 106 107 108 109 110 111 112 113 |
|
mindone.diffusers.utils.logging.enable_default_handler()
¶
Enable the default handler of the ๐ค Diffusers' root logger.
Source code in mindone/diffusers/utils/logging.py
184 185 186 187 188 189 190 |
|
mindone.diffusers.utils.logging.disable_default_handler()
¶
Disable the default handler of the ๐ค Diffusers' root logger.
Source code in mindone/diffusers/utils/logging.py
175 176 177 178 179 180 181 |
|
mindone.diffusers.utils.logging.enable_explicit_format()
¶
Enable explicit formatting for every ๐ค Diffusers' logger. The explicit formatter is as follows:
[LEVELNAME|FILENAME|LINE NUMBER] TIME >> MESSAGE
Source code in mindone/diffusers/utils/logging.py
230 231 232 233 234 235 236 237 238 239 240 241 242 |
|
mindone.diffusers.utils.logging.reset_format()
¶
Resets the formatting for ๐ค Diffusers' loggers.
All handlers currently bound to the root logger are affected by this method.
Source code in mindone/diffusers/utils/logging.py
245 246 247 248 249 250 251 252 253 254 |
|
mindone.diffusers.utils.logging.enable_progress_bar()
¶
Enable tqdm progress bar.
Source code in mindone/diffusers/utils/logging.py
321 322 323 324 |
|
mindone.diffusers.utils.logging.disable_progress_bar()
¶
Disable tqdm progress bar.
Source code in mindone/diffusers/utils/logging.py
327 328 329 330 |
|