Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
ICV-mmengine_basecode
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Florian Schiffel
ICV-mmengine_basecode
Commits
ec72f59b
Unverified
Commit
ec72f59b
authored
2 years ago
by
Mashiro
Committed by
GitHub
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[Enhance] Remove blink info and debug level message (#371)
* remove blink info debug msg * minor refine * minor refine
parent
f3189918
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
mmengine/logging/logger.py
+18
-11
18 additions, 11 deletions
mmengine/logging/logger.py
with
18 additions
and
11 deletions
mmengine/logging/logger.py
+
18
−
11
View file @
ec72f59b
...
@@ -19,18 +19,24 @@ class MMFormatter(logging.Formatter):
...
@@ -19,18 +19,24 @@ class MMFormatter(logging.Formatter):
Args:
Args:
color (bool): Whether to use colorful format. filehandler is not
color (bool): Whether to use colorful format. filehandler is not
allowed to use color format, otherwise it will be garbled.
allowed to use color format, otherwise it will be garbled.
blink (bool): Whether to blink the ``INFO`` and ``DEBUG`` logging
level.
**kwargs: Keyword arguments passed to
:meth:`logging.Formatter.__init__`.
"""
"""
_color_mapping
:
dict
=
dict
(
_color_mapping
:
dict
=
dict
(
ERROR
=
'
red
'
,
WARNING
=
'
yellow
'
,
INFO
=
'
white
'
,
DEBUG
=
'
green
'
)
ERROR
=
'
red
'
,
WARNING
=
'
yellow
'
,
INFO
=
'
white
'
,
DEBUG
=
'
green
'
)
def
__init__
(
self
,
color
:
bool
=
True
,
**
kwargs
):
def
__init__
(
self
,
color
:
bool
=
True
,
blink
:
bool
=
False
,
**
kwargs
):
super
().
__init__
(
**
kwargs
)
super
().
__init__
(
**
kwargs
)
assert
not
(
not
color
and
blink
),
(
'
blink should only be available when color is True
'
)
# Get prefix format according to color.
# Get prefix format according to color.
error_prefix
=
self
.
_get_prefix
(
'
ERROR
'
,
color
)
error_prefix
=
self
.
_get_prefix
(
'
ERROR
'
,
color
,
blink
=
True
)
warn_prefix
=
self
.
_get_prefix
(
'
WARNING
'
,
color
)
warn_prefix
=
self
.
_get_prefix
(
'
WARNING
'
,
color
,
blink
=
True
)
info_prefix
=
self
.
_get_prefix
(
'
INFO
'
,
color
)
info_prefix
=
self
.
_get_prefix
(
'
INFO
'
,
color
,
blink
)
debug_prefix
=
self
.
_get_prefix
(
'
DEBUG
'
,
color
)
debug_prefix
=
self
.
_get_prefix
(
'
DEBUG
'
,
color
,
blink
)
# Config output format.
# Config output format.
self
.
err_format
=
(
f
'
%(asctime)s - %(name)s -
{
error_prefix
}
-
'
self
.
err_format
=
(
f
'
%(asctime)s - %(name)s -
{
error_prefix
}
-
'
'
%(pathname)s - %(funcName)s - %(lineno)d -
'
'
%(pathname)s - %(funcName)s - %(lineno)d -
'
...
@@ -42,21 +48,22 @@ class MMFormatter(logging.Formatter):
...
@@ -42,21 +48,22 @@ class MMFormatter(logging.Formatter):
self
.
debug_format
=
(
f
'
%(asctime)s - %(name)s -
{
debug_prefix
}
- %(
'
self
.
debug_format
=
(
f
'
%(asctime)s - %(name)s -
{
debug_prefix
}
- %(
'
'
message)s
'
)
'
message)s
'
)
def
_get_prefix
(
self
,
level
:
str
,
color
:
bool
)
->
str
:
def
_get_prefix
(
self
,
level
:
str
,
color
:
bool
,
blink
=
False
)
->
str
:
"""
Get the prefix of the target log level.
"""
Get the prefix of the target log level.
Args:
Args:
level (str): log level.
level (str): log level.
color (bool): Whether to get colorful prefix.
color (bool): Whether to get colorful prefix.
blink (bool): Whether the prefix will blink.
Returns:
Returns:
str: The plain or colorful prefix.
str: The plain or colorful prefix.
"""
"""
if
color
:
if
color
:
prefix
=
colored
(
attrs
=
[
'
underline
'
]
level
,
if
blink
:
self
.
_color_mapping
[
level
],
attrs
.
append
(
'
blink
'
)
attrs
=
[
'
blink
'
,
'
underline
'
]
)
prefix
=
colored
(
level
,
self
.
_color_mapping
[
level
],
attrs
=
attrs
)
else
:
else
:
prefix
=
level
prefix
=
level
return
prefix
return
prefix
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment