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
62ea8b89
Commit
62ea8b89
authored
Nov 16, 2019
by
Ozzieisaacs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Logging to stdout, proposal form #1078
parent
a4416c20
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
4 deletions
+10
-4
logger.py
cps/logger.py
+10
-4
No files found.
cps/logger.py
View file @
62ea8b89
...
...
@@ -18,6 +18,7 @@
from
__future__
import
division
,
print_function
,
unicode_literals
import
os
import
sys
import
inspect
import
logging
from
logging
import
Formatter
,
StreamHandler
...
...
@@ -34,6 +35,7 @@ DEFAULT_LOG_LEVEL = logging.INFO
DEFAULT_LOG_FILE
=
os
.
path
.
join
(
_CONFIG_DIR
,
"calibre-web.log"
)
DEFAULT_ACCESS_LOG
=
os
.
path
.
join
(
_CONFIG_DIR
,
"access.log"
)
LOG_TO_STDERR
=
'/dev/stderr'
LOG_TO_STDOUT
=
'/dev/stdout'
logging
.
addLevelName
(
logging
.
WARNING
,
"WARN"
)
logging
.
addLevelName
(
logging
.
CRITICAL
,
"CRIT"
)
...
...
@@ -112,9 +114,13 @@ def setup(log_file, log_level=None):
return
logging
.
debug
(
"logging to
%
s level
%
s"
,
log_file
,
r
.
level
)
if
log_file
==
LOG_TO_STDERR
:
if
log_file
==
LOG_TO_STDERR
or
log_file
==
LOG_TO_STDOUT
:
if
log_file
==
LOG_TO_STDOUT
:
file_handler
=
StreamHandler
(
sys
.
stdout
)
file_handler
.
baseFilename
=
log_file
else
:
file_handler
=
StreamHandler
()
file_handler
.
baseFilename
=
LOG_TO_STDERR
file_handler
.
baseFilename
=
log_file
else
:
try
:
file_handler
=
RotatingFileHandler
(
log_file
,
maxBytes
=
50000
,
backupCount
=
2
)
...
...
@@ -164,5 +170,5 @@ class StderrLogger(object):
self
.
log
.
debug
(
"Logging Error"
)
# default configuration, before application settngs are applied
# default configuration, before application sett
i
ngs 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