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
6d1a3ccd
Commit
6d1a3ccd
authored
Mar 28, 2020
by
Ozzie Isaacs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve logger for windows
parent
98181fe2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
5 deletions
+8
-5
__init__.py
cps/__init__.py
+2
-3
logger.py
cps/logger.py
+6
-2
No files found.
cps/__init__.py
View file @
6d1a3ccd
...
@@ -33,11 +33,10 @@ from flask_login import LoginManager
...
@@ -33,11 +33,10 @@ from flask_login import LoginManager
from
flask_babel
import
Babel
from
flask_babel
import
Babel
from
flask_principal
import
Principal
from
flask_principal
import
Principal
from
.
import
logger
,
cache_buster
,
cli
,
config_sql
,
ub
,
db
,
services
from
.
import
config_sql
,
logger
,
cache_buster
,
cli
,
ub
,
db
from
.reverseproxy
import
ReverseProxied
from
.reverseproxy
import
ReverseProxied
from
.server
import
WebServer
from
.server
import
WebServer
mimetypes
.
init
()
mimetypes
.
init
()
mimetypes
.
add_type
(
'application/xhtml+xml'
,
'.xhtml'
)
mimetypes
.
add_type
(
'application/xhtml+xml'
,
'.xhtml'
)
mimetypes
.
add_type
(
'application/epub+zip'
,
'.epub'
)
mimetypes
.
add_type
(
'application/epub+zip'
,
'.epub'
)
...
@@ -62,7 +61,6 @@ lm = LoginManager()
...
@@ -62,7 +61,6 @@ lm = LoginManager()
lm
.
login_view
=
'web.login'
lm
.
login_view
=
'web.login'
lm
.
anonymous_user
=
ub
.
Anonymous
lm
.
anonymous_user
=
ub
.
Anonymous
ub
.
init_db
(
cli
.
settingspath
)
ub
.
init_db
(
cli
.
settingspath
)
# pylint: disable=no-member
# pylint: disable=no-member
config
=
config_sql
.
load_configuration
(
ub
.
session
)
config
=
config_sql
.
load_configuration
(
ub
.
session
)
...
@@ -75,6 +73,7 @@ _BABEL_TRANSLATIONS = set()
...
@@ -75,6 +73,7 @@ _BABEL_TRANSLATIONS = set()
log
=
logger
.
create
()
log
=
logger
.
create
()
from
.
import
services
def
create_app
():
def
create_app
():
app
.
wsgi_app
=
ReverseProxied
(
app
.
wsgi_app
)
app
.
wsgi_app
=
ReverseProxied
(
app
.
wsgi_app
)
...
...
cps/logger.py
View file @
6d1a3ccd
...
@@ -67,6 +67,8 @@ def get_level_name(level):
...
@@ -67,6 +67,8 @@ def get_level_name(level):
def
is_valid_logfile
(
file_path
):
def
is_valid_logfile
(
file_path
):
if
file_path
==
LOG_TO_STDERR
or
file_path
==
LOG_TO_STDOUT
:
return
True
if
not
file_path
:
if
not
file_path
:
return
True
return
True
if
os
.
path
.
isdir
(
file_path
):
if
os
.
path
.
isdir
(
file_path
):
...
@@ -105,7 +107,9 @@ def setup(log_file, log_level=None):
...
@@ -105,7 +107,9 @@ 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
)
# Otherwise name get's destroyed on windows
if
log_file
!=
LOG_TO_STDERR
and
log_file
!=
LOG_TO_STDOUT
:
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
:
...
@@ -119,7 +123,7 @@ def setup(log_file, log_level=None):
...
@@ -119,7 +123,7 @@ def setup(log_file, log_level=None):
file_handler
=
StreamHandler
(
sys
.
stdout
)
file_handler
=
StreamHandler
(
sys
.
stdout
)
file_handler
.
baseFilename
=
log_file
file_handler
.
baseFilename
=
log_file
else
:
else
:
file_handler
=
StreamHandler
()
file_handler
=
StreamHandler
(
sys
.
stderr
)
file_handler
.
baseFilename
=
log_file
file_handler
.
baseFilename
=
log_file
else
:
else
:
try
:
try
:
...
...
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