Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Overbill1683
Stable Diffusion Webui
提交
a06dab8d
S
Stable Diffusion Webui
项目概览
Overbill1683
/
Stable Diffusion Webui
10 个月 前同步成功
通知
1746
Star
81
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
分析
仓库
DevOps
项目成员
Pages
S
Stable Diffusion Webui
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Pages
分析
分析
仓库分析
DevOps
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
提交
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
a06dab8d
编写于
1月 05, 2024
作者:
A
AUTOMATIC1111
提交者:
GitHub
1月 05, 2024
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #14538 from akx/log-wut
Fix logging configuration again
上级
6ffbff08
6fa42e91
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
39 addition
and
23 deletion
+39
-23
modules/logging_config.py
modules/logging_config.py
+39
-23
未找到文件。
modules/logging_config.py
浏览文件 @
a06dab8d
import
os
import
logging
import
os
try
:
from
tqdm.auto
import
tqdm
from
tqdm
import
tqdm
class
TqdmLoggingHandler
(
logging
.
Handler
):
def
__init__
(
self
,
level
=
logging
.
INFO
):
super
().
__init__
(
level
)
def
__init__
(
self
,
fallback_handler
:
logging
.
Handler
):
super
().
__init__
()
self
.
fallback_handler
=
fallback_handler
def
emit
(
self
,
record
):
try
:
msg
=
self
.
format
(
record
)
tqdm
.
write
(
msg
)
self
.
flush
()
# If there are active tqdm progress bars,
# attempt to not interfere with them.
if
tqdm
.
_instances
:
tqdm
.
write
(
self
.
format
(
record
))
else
:
self
.
fallback_handler
.
emit
(
record
)
except
Exception
:
self
.
handleError
(
record
)
self
.
fallback_handler
.
emit
(
record
)
TQDM_IMPORTED
=
True
except
ImportError
:
# tqdm does not exist before first launch
# I will import once the UI finishes seting up the enviroment and reloads.
TQDM_IMPORTED
=
False
TqdmLoggingHandler
=
None
def
setup_logging
(
loglevel
):
if
loglevel
is
None
:
loglevel
=
os
.
environ
.
get
(
"SD_WEBUI_LOG_LEVEL"
)
loghandlers
=
[]
if
not
loglevel
:
return
if
logging
.
root
.
handlers
:
# Already configured, do not interfere
return
if
os
.
environ
.
get
(
"SD_WEBUI_RICH_LOG"
):
from
rich.logging
import
RichHandler
handler
=
RichHandler
()
else
:
handler
=
logging
.
StreamHandler
()
if
TqdmLoggingHandler
:
handler
=
TqdmLoggingHandler
(
handler
)
formatter
=
logging
.
Formatter
(
'%(asctime)s %(levelname)s [%(name)s] %(message)s'
,
'%Y-%m-%d %H:%M:%S'
,
)
if
TQDM_IMPORTED
:
loghandlers
.
append
(
TqdmLoggingHandler
())
handler
.
setFormatter
(
formatter
)
if
loglevel
:
log_level
=
getattr
(
logging
,
loglevel
.
upper
(),
None
)
or
logging
.
INFO
logging
.
basicConfig
(
level
=
log_level
,
format
=
'%(asctime)s %(levelname)s [%(name)s] %(message)s'
,
datefmt
=
'%Y-%m-%d %H:%M:%S'
,
handlers
=
loghandlers
)
log_level
=
getattr
(
logging
,
loglevel
.
upper
(),
None
)
or
logging
.
INFO
logging
.
root
.
setLevel
(
log_level
)
logging
.
root
.
addHandler
(
handler
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录