Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
nopaque
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SFB 1288 - INF
nopaque
Commits
2991082f
Commit
2991082f
authored
5 years ago
by
Stephan Porada
Browse files
Options
Downloads
Patches
Plain Diff
Add different logging levels.
parent
682ca309
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
config.py
+18
-14
18 additions, 14 deletions
config.py
with
18 additions
and
14 deletions
config.py
+
18
−
14
View file @
2991082f
...
...
@@ -40,13 +40,15 @@ class DevelopmentConfig(Config):
file_path
=
os
.
path
.
join
(
os
.
getcwd
(),
'
logs/opaque_web.log
'
)
log
=
open
(
file_path
,
'
w+
'
)
log
.
close
()
log_format
=
(
"
%(asctime)s - %(levelname)s - %(name)s -
"
"
%(filename)s - %(lineno)d - %(message)s
"
)
logging
.
basicConfig
(
filename
=
'
logs/opaque_web.log
'
,
level
=
'
WARNING
'
,
format
=
log_format
,
datefmt
=
'
%Y-%m-%d %H:%M:%S
'
,
filemode
=
'
w
'
)
logger
=
logging
.
getLogger
(
__name__
)
logger
.
warning
(
'
Logging has started with level WARNING.
'
)
if
os
.
environ
.
get
(
'
FLASK_CONFIG
'
)
==
'
development
'
:
log_format
=
(
"
%(asctime)s - %(levelname)s - %(name)s -
"
"
%(filename)s - %(lineno)d - %(message)s
"
)
logging
.
basicConfig
(
filename
=
'
logs/opaque_web.log
'
,
level
=
'
WARNING
'
,
format
=
log_format
,
datefmt
=
'
%Y-%m-%d %H:%M:%S
'
,
filemode
=
'
w
'
)
logger
=
logging
.
getLogger
(
__name__
)
logger
.
warning
(
'
Logging has started with level WARNING.
'
'
From development config.
'
)
class
TestingConfig
(
Config
):
...
...
@@ -71,13 +73,15 @@ class ProductionConfig(Config):
file_path
=
os
.
path
.
join
(
os
.
getcwd
(),
'
logs/opaque_web.log
'
)
log
=
open
(
file_path
,
'
w+
'
)
log
.
close
()
log_format
=
(
"
%(asctime)s - %(levelname)s - %(name)s -
"
"
%(filename)s - %(lineno)d - %(message)s
"
)
logging
.
basicConfig
(
filename
=
'
logs/opaque_web.log
'
,
level
=
'
ERROR
'
,
format
=
log_format
,
datefmt
=
'
%Y-%m-%d %H:%M:%S
'
,
filemode
=
'
w
'
)
logger
=
logging
.
getLogger
(
__name__
)
logger
.
error
(
'
Logging has started with level ERROR.
'
)
if
os
.
environ
.
get
(
'
FLASK_CONFIG
'
)
==
'
production
'
:
log_format
=
(
"
%(asctime)s - %(levelname)s - %(name)s -
"
"
%(filename)s - %(lineno)d - %(message)s
"
)
logging
.
basicConfig
(
filename
=
'
logs/opaque_web.log
'
,
level
=
'
ERROR
'
,
format
=
log_format
,
datefmt
=
'
%Y-%m-%d %H:%M:%S
'
,
filemode
=
'
w
'
)
logger
=
logging
.
getLogger
(
__name__
)
logger
.
error
(
'
Logging has started with level ERROR.
'
'
From production config.
'
)
config
=
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment