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
e411c0fd
Commit
e411c0fd
authored
Jul 14, 2019
by
Ozzieisaacs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix logging in debug mode
parent
4708347c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
12 deletions
+22
-12
constants.py
cps/constants.py
+9
-1
gdriveutils.py
cps/gdriveutils.py
+4
-4
logger.py
cps/logger.py
+9
-7
No files found.
cps/constants.py
View file @
e411c0fd
...
...
@@ -22,6 +22,7 @@ import sys
import
os
from
collections
import
namedtuple
HOME_CONFIG
=
False
# Base dir is parent of current file, necessary if called from different folder
if
sys
.
version_info
<
(
3
,
0
):
...
...
@@ -33,7 +34,14 @@ else:
STATIC_DIR
=
os
.
path
.
join
(
BASE_DIR
,
'cps'
,
'static'
)
TEMPLATES_DIR
=
os
.
path
.
join
(
BASE_DIR
,
'cps'
,
'templates'
)
TRANSLATIONS_DIR
=
os
.
path
.
join
(
BASE_DIR
,
'cps'
,
'translations'
)
CONFIG_DIR
=
os
.
environ
.
get
(
'CALIBRE_DBPATH'
,
BASE_DIR
)
if
HOME_CONFIG
:
home_dir
=
os
.
path
.
join
(
os
.
path
.
expanduser
(
"~"
),
".calibre-web"
)
if
not
os
.
path
.
exists
(
home_dir
):
os
.
makedirs
(
home_dir
)
CONFIG_DIR
=
os
.
environ
.
get
(
'CALIBRE_DBPATH'
,
home_dir
)
else
:
CONFIG_DIR
=
os
.
environ
.
get
(
'CALIBRE_DBPATH'
,
BASE_DIR
)
ROLE_USER
=
0
<<
0
...
...
cps/gdriveutils.py
View file @
e411c0fd
...
...
@@ -39,12 +39,12 @@ except ImportError:
gdrive_support
=
False
from
.
import
logger
,
cli
,
config
from
.constants
import
BASE_DIR
as
_BASE
_DIR
from
.constants
import
CONFIG_DIR
as
_CONFIG
_DIR
SETTINGS_YAML
=
os
.
path
.
join
(
_
BASE
_DIR
,
'settings.yaml'
)
CREDENTIALS
=
os
.
path
.
join
(
_
BASE
_DIR
,
'gdrive_credentials'
)
CLIENT_SECRETS
=
os
.
path
.
join
(
_
BASE
_DIR
,
'client_secrets.json'
)
SETTINGS_YAML
=
os
.
path
.
join
(
_
CONFIG
_DIR
,
'settings.yaml'
)
CREDENTIALS
=
os
.
path
.
join
(
_
CONFIG
_DIR
,
'gdrive_credentials'
)
CLIENT_SECRETS
=
os
.
path
.
join
(
_
CONFIG
_DIR
,
'client_secrets.json'
)
log
=
logger
.
create
()
...
...
cps/logger.py
View file @
e411c0fd
...
...
@@ -23,7 +23,7 @@ import logging
from
logging
import
Formatter
,
StreamHandler
from
logging.handlers
import
RotatingFileHandler
from
.constants
import
BASE_DIR
as
_BASE
_DIR
from
.constants
import
CONFIG_DIR
as
_CONFIG
_DIR
ACCESS_FORMATTER_GEVENT
=
Formatter
(
"
%(message)
s"
)
...
...
@@ -31,8 +31,8 @@ ACCESS_FORMATTER_TORNADO = Formatter("[%(asctime)s] %(message)s")
FORMATTER
=
Formatter
(
"[
%(asctime)
s]
%(levelname)5
s {
%(name)
s:
%(lineno)
d}
%(message)
s"
)
DEFAULT_LOG_LEVEL
=
logging
.
INFO
DEFAULT_LOG_FILE
=
os
.
path
.
join
(
_
BASE
_DIR
,
"calibre-web.log"
)
DEFAULT_ACCESS_LOG
=
os
.
path
.
join
(
_
BASE
_DIR
,
"access.log"
)
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'
logging
.
addLevelName
(
logging
.
WARNING
,
"WARN"
)
...
...
@@ -76,7 +76,7 @@ def is_valid_logfile(file_path):
def
_absolute_log_file
(
log_file
,
default_log_file
):
if
log_file
:
if
not
os
.
path
.
dirname
(
log_file
):
log_file
=
os
.
path
.
join
(
_
BASE
_DIR
,
log_file
)
log_file
=
os
.
path
.
join
(
_
CONFIG
_DIR
,
log_file
)
return
os
.
path
.
abspath
(
log_file
)
return
default_log_file
...
...
@@ -95,6 +95,11 @@ def setup(log_file, log_level=None):
Configure the logging output.
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
)
r
=
logging
.
root
...
...
@@ -159,6 +164,3 @@ class StderrLogger(object):
self
.
log
.
debug
(
"Logging Error"
)
# if debugging, start logging to stderr immediately
if
os
.
environ
.
get
(
'FLASK_DEBUG'
,
None
):
setup
(
LOG_TO_STDERR
,
logging
.
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