Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
D
douban-api-proxy
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
captainwong
douban-api-proxy
Commits
7c503b4a
Commit
7c503b4a
authored
Jul 31, 2019
by
Daniel Pavel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
provide a default logging configuration (fixes #987)
parent
5f25b810
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
7 deletions
+6
-7
logger.py
cps/logger.py
+6
-7
No files found.
cps/logger.py
View file @
7c503b4a
...
@@ -95,13 +95,6 @@ def setup(log_file, log_level=None):
...
@@ -95,13 +95,6 @@ def setup(log_file, log_level=None):
Configure the logging output.
Configure the logging output.
May be called multiple times.
May be called multiple times.
'''
'''
# if debugging, start logging to stderr immediately
if
os
.
environ
.
get
(
'FLASK_DEBUG'
,
None
):
log_file
=
LOG_TO_STDERR
log_level
=
logging
.
DEBUG
log_file
=
_absolute_log_file
(
log_file
,
DEFAULT_LOG_FILE
)
log_level
=
log_level
or
DEFAULT_LOG_LEVEL
log_level
=
log_level
or
DEFAULT_LOG_LEVEL
logging
.
getLogger
(
__package__
)
.
setLevel
(
log_level
)
logging
.
getLogger
(
__package__
)
.
setLevel
(
log_level
)
...
@@ -110,6 +103,8 @@ def setup(log_file, log_level=None):
...
@@ -110,6 +103,8 @@ def setup(log_file, log_level=None):
# avoid spamming the log with debug messages from libraries
# avoid spamming the log with debug messages from libraries
r
.
setLevel
(
log_level
)
r
.
setLevel
(
log_level
)
log_file
=
_absolute_log_file
(
log_file
,
DEFAULT_LOG_FILE
)
previous_handler
=
r
.
handlers
[
0
]
if
r
.
handlers
else
None
previous_handler
=
r
.
handlers
[
0
]
if
r
.
handlers
else
None
if
previous_handler
:
if
previous_handler
:
# if the log_file has not changed, don't create a new handler
# if the log_file has not changed, don't create a new handler
...
@@ -167,3 +162,7 @@ class StderrLogger(object):
...
@@ -167,3 +162,7 @@ class StderrLogger(object):
self
.
buffer
+=
message
self
.
buffer
+=
message
except
Exception
:
except
Exception
:
self
.
log
.
debug
(
"Logging Error"
)
self
.
log
.
debug
(
"Logging Error"
)
# default configuration, before application settngs are applied
setup
(
LOG_TO_STDERR
,
logging
.
DEBUG
if
os
.
environ
.
get
(
'FLASK_DEBUG'
)
else
DEFAULT_LOG_LEVEL
)
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