Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
S
Stable Diffusion Webui
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
novelai-storage
Stable Diffusion Webui
Commits
a06dab8d
Commit
a06dab8d
authored
Jan 05, 2024
by
AUTOMATIC1111
Committed by
GitHub
Jan 05, 2024
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #14538 from akx/log-wut
Fix logging configuration again
parents
6ffbff08
6fa42e91
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
23 deletions
+39
-23
modules/logging_config.py
modules/logging_config.py
+39
-23
No files found.
modules/logging_config.py
View file @
a06dab8d
import
os
import
logging
import
logging
import
os
try
:
try
:
from
tqdm.auto
import
tqdm
from
tqdm
import
tqdm
class
TqdmLoggingHandler
(
logging
.
Handler
):
class
TqdmLoggingHandler
(
logging
.
Handler
):
def
__init__
(
self
,
level
=
logging
.
INFO
):
def
__init__
(
self
,
fallback_handler
:
logging
.
Handler
):
super
()
.
__init__
(
level
)
super
()
.
__init__
()
self
.
fallback_handler
=
fallback_handler
def
emit
(
self
,
record
):
def
emit
(
self
,
record
):
try
:
try
:
msg
=
self
.
format
(
record
)
# If there are active tqdm progress bars,
tqdm
.
write
(
msg
)
# attempt to not interfere with them.
self
.
flush
()
if
tqdm
.
_instances
:
tqdm
.
write
(
self
.
format
(
record
))
else
:
self
.
fallback_handler
.
emit
(
record
)
except
Exception
:
except
Exception
:
self
.
handleError
(
record
)
self
.
fallback_handler
.
emit
(
record
)
TQDM_IMPORTED
=
True
except
ImportError
:
except
ImportError
:
# tqdm does not exist before first launch
TqdmLoggingHandler
=
None
# I will import once the UI finishes seting up the enviroment and reloads.
TQDM_IMPORTED
=
False
def
setup_logging
(
loglevel
):
def
setup_logging
(
loglevel
):
if
loglevel
is
None
:
if
loglevel
is
None
:
loglevel
=
os
.
environ
.
get
(
"SD_WEBUI_LOG_LEVEL"
)
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
:
handler
.
setFormatter
(
formatter
)
loghandlers
.
append
(
TqdmLoggingHandler
())
if
loglevel
:
log_level
=
getattr
(
logging
,
loglevel
.
upper
(),
None
)
or
logging
.
INFO
log_level
=
getattr
(
logging
,
loglevel
.
upper
(),
None
)
or
logging
.
INFO
logging
.
root
.
setLevel
(
log_level
)
logging
.
basicConfig
(
logging
.
root
.
addHandler
(
handler
)
level
=
log_level
,
format
=
'
%(asctime)
s
%(levelname)
s [
%(name)
s]
%(message)
s'
,
datefmt
=
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S'
,
handlers
=
loghandlers
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment