Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
setuptools
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
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
Jérome Perrin
setuptools
Commits
6b2531b4
Commit
6b2531b4
authored
Jun 04, 2002
by
Jeremy Hylton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
A simple log mechanism styled after the proposed std library module
parent
bbf5c4f0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
56 additions
and
0 deletions
+56
-0
log.py
log.py
+56
-0
No files found.
log.py
0 → 100644
View file @
6b2531b4
"""A simple log mechanism styled after PEP 282."""
# The class here is styled after PEP 282 so that it could later be
# replaced with a standard Python logging implementation.
DEBUG
=
1
INFO
=
2
WARN
=
3
ERROR
=
4
FATAL
=
5
class
Log
:
def
__init__
(
self
,
threshold
=
WARN
):
self
.
threshold
=
threshold
def
_log
(
self
,
level
,
msg
,
args
):
if
level
>=
self
.
threshold
:
print
msg
%
args
def
log
(
self
,
level
,
msg
,
*
args
):
self
.
_log
(
level
,
msg
,
args
)
def
debug
(
self
,
msg
,
*
args
):
self
.
_log
(
DEBUG
,
msg
,
args
)
def
info
(
self
,
msg
,
*
args
):
self
.
_log
(
INFO
,
msg
,
args
)
def
warn
(
self
,
msg
,
*
args
):
self
.
_log
(
WARN
,
msg
,
args
)
def
error
(
self
,
msg
,
*
args
):
self
.
_log
(
ERROR
,
msg
,
args
)
def
fatal
(
self
,
msg
,
*
args
):
self
.
_log
(
FATAL
,
msg
,
args
)
_global_log
=
Log
()
log
=
_global_log
.
log
debug
=
_global_log
.
debug
info
=
_global_log
.
info
warn
=
_global_log
.
warn
error
=
_global_log
.
error
fatal
=
_global_log
.
fatal
def
set_threshold
(
level
):
_global_log
.
threshold
=
level
def
set_verbosity
(
v
):
if
v
==
0
:
set_threshold
(
WARN
)
if
v
==
1
:
set_threshold
(
INFO
)
if
v
==
2
:
set_threshold
(
DEBUG
)
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