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
172 173 174 |
|
mindone.diffusers.utils.logging.set_verbosity_warning()
¶
Set the verbosity to the WARNING
level.
Source code in mindone/diffusers/utils/logging.py
162 163 164 |
|
mindone.diffusers.utils.logging.set_verbosity_info()
¶
Set the verbosity to the INFO
level.
Source code in mindone/diffusers/utils/logging.py
157 158 159 |
|
mindone.diffusers.utils.logging.set_verbosity_debug()
¶
Set the verbosity to the DEBUG
level.
Source code in mindone/diffusers/utils/logging.py
167 168 169 |
|
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
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
|
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
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
|
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
104 105 106 107 108 109 110 111 112 113 114 115 |
|
mindone.diffusers.utils.logging.enable_default_handler()
¶
Enable the default handler of the ๐ค Diffusers' root logger.
Source code in mindone/diffusers/utils/logging.py
186 187 188 189 190 191 192 |
|
mindone.diffusers.utils.logging.disable_default_handler()
¶
Disable the default handler of the ๐ค Diffusers' root logger.
Source code in mindone/diffusers/utils/logging.py
177 178 179 180 181 182 183 |
|
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
232 233 234 235 236 237 238 239 240 241 242 243 244 |
|
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
247 248 249 250 251 252 253 254 255 256 |
|
mindone.diffusers.utils.logging.enable_progress_bar()
¶
Enable tqdm progress bar.
Source code in mindone/diffusers/utils/logging.py
323 324 325 326 |
|
mindone.diffusers.utils.logging.disable_progress_bar()
¶
Disable tqdm progress bar.
Source code in mindone/diffusers/utils/logging.py
329 330 331 332 |
|