Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
ColossalAI
Commits
7be397ca
Unverified
Commit
7be397ca
authored
Mar 25, 2022
by
ver217
Committed by
GitHub
Mar 25, 2022
Browse files
[log] polish disable_existing_loggers (#519)
parent
0bebda6e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
8 deletions
+17
-8
colossalai/logging/__init__.py
colossalai/logging/__init__.py
+17
-8
colossalai/logging/logger.py
colossalai/logging/logger.py
+0
-0
No files found.
colossalai/logging/__init__.py
View file @
7be397ca
from
typing
import
List
from
.logging
import
DistributedLogger
import
logging
import
logging
from
typing
import
List
,
Optional
__all__
=
[
'get_dist_logger'
,
'DistributedLogger'
]
from
.logger
import
DistributedLogger
__all__
=
[
'get_dist_logger'
,
'DistributedLogger'
,
'disable_existing_loggers'
]
def
get_dist_logger
(
name
=
'colossalai'
):
def
get_dist_logger
(
name
=
'colossalai'
):
...
@@ -18,12 +19,20 @@ def get_dist_logger(name='colossalai'):
...
@@ -18,12 +19,20 @@ def get_dist_logger(name='colossalai'):
return
DistributedLogger
.
get_instance
(
name
=
name
)
return
DistributedLogger
.
get_instance
(
name
=
name
)
def
disable_existing_loggers
(
except_loggers
:
List
[
str
]
=
[
'colossalai'
]):
def
disable_existing_loggers
(
include
:
Optional
[
List
[
str
]]
=
None
,
exclude
:
List
[
str
]
=
[
'colossalai'
]):
"""Set the level of existing loggers to `WARNING`.
"""Set the level of existing loggers to `WARNING`.
By default, it will "disable" all existing loggers except the logger named "colossalai".
:param except_loggers: loggers in this `list` will be ignored when disabling, defaults to ['colossalai']
Args:
:type except_loggers: list, optional
include (Optional[List[str]], optional): Loggers whose name in this list will be disabled.
If set to `None`, `exclude` argument will be used. Defaults to None.
exclude (List[str], optional): Loggers whose name not in this list will be disabled.
This argument will be used only when `include` is None. Defaults to ['colossalai'].
"""
"""
if
include
is
None
:
filter_func
=
lambda
name
:
name
not
in
exclude
else
:
filter_func
=
lambda
name
:
name
in
include
for
log_name
in
logging
.
Logger
.
manager
.
loggerDict
.
keys
():
for
log_name
in
logging
.
Logger
.
manager
.
loggerDict
.
keys
():
if
log_name
not
in
except_loggers
:
if
filter_func
(
log_name
)
:
logging
.
getLogger
(
log_name
).
setLevel
(
logging
.
WARNING
)
logging
.
getLogger
(
log_name
).
setLevel
(
logging
.
WARNING
)
colossalai/logging/logg
ing
.py
→
colossalai/logging/logg
er
.py
View file @
7be397ca
File moved
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