Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Plio
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
aflab
astrogeology
Plio
Commits
3a7860ef
Commit
3a7860ef
authored
8 years ago
by
jlaura
Committed by
Jason R Laura
8 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Fixes regression in logging.
parent
1ab927eb
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
plio/utils/log.py
+10
-11
10 additions, 11 deletions
plio/utils/log.py
plio/utils/tests/test_log.py
+3
-3
3 additions, 3 deletions
plio/utils/tests/test_log.py
with
13 additions
and
14 deletions
plio/utils/log.py
+
10
−
11
View file @
3a7860ef
...
@@ -5,39 +5,38 @@ import logging.config
...
@@ -5,39 +5,38 @@ import logging.config
from
..examples
import
get_path
from
..examples
import
get_path
def
setup_logging
(
default_
path
=
get_path
(
'
logging.json
'
),
def
setup_logging
(
path
=
get_path
(
'
logging.json
'
),
default_
level
=
'
INFO
'
,
level
=
'
INFO
'
,
env_key
=
'
LOG_CFG
'
):
env_key
=
'
LOG_CFG
'
):
"""
"""
Read a log configuration file, written in JSON
Read a log configuration file, written in JSON
Parameters
Parameters
----------
----------
default_
path : string
path : string
The path to the logging configuration file
The path to the logging configuration file
default_
level : object
level : object
The logger level at which to report
The logger level at which to report
env_key : str
env_key : str
A potential environment variable where the user defaults logs
A potential environment variable where the user defaults logs
"""
"""
path
=
default_path
value
=
os
.
getenv
(
env_key
,
None
)
value
=
os
.
getenv
(
env_key
,
None
)
if
value
:
if
value
:
path
=
value
path
=
value
default_level
=
getattr
(
logging
,
default_level
.
upper
())
print
(
level
)
level
=
getattr
(
logging
,
level
.
upper
())
print
(
level
)
if
os
.
path
.
exists
(
path
):
if
os
.
path
.
exists
(
path
):
logtype
=
os
.
path
.
splitext
(
os
.
path
.
basename
(
path
))[
1
]
logtype
=
os
.
path
.
splitext
(
os
.
path
.
basename
(
path
))[
1
]
with
open
(
path
,
'
rt
'
)
as
f
:
with
open
(
path
,
'
rt
'
)
as
f
:
if
logtype
==
'
.json
'
:
if
logtype
==
'
.json
'
:
config
=
json
.
load
(
f
,
parse_float
=
True
,
config
=
json
.
load
(
f
)
parse_int
=
True
)
elif
logtype
==
'
.yaml
'
:
elif
logtype
==
'
.yaml
'
:
import
yaml
import
yaml
config
=
yaml
.
load
(
f
.
read
())
config
=
yaml
.
load
(
f
.
read
())
logging
.
config
.
dictConfig
(
config
)
logging
.
config
.
dictConfig
(
config
)
else
:
else
:
logging
.
basicConfig
(
level
=
default_
level
)
logging
.
basicConfig
(
level
=
level
)
logger
=
logging
.
getLogger
()
logger
=
logging
.
getLogger
()
logger
.
setLevel
(
default_level
)
logger
.
setLevel
(
level
)
\ No newline at end of file
\ No newline at end of file
This diff is collapsed.
Click to expand it.
plio/utils/tests/test_log.py
+
3
−
3
View file @
3a7860ef
...
@@ -12,17 +12,17 @@ class TestLog(unittest.TestCase):
...
@@ -12,17 +12,17 @@ class TestLog(unittest.TestCase):
pass
pass
def
test_setup_json
(
self
):
def
test_setup_json
(
self
):
log
.
setup_logging
(
default_
path
=
get_path
(
'
logging.json
'
))
log
.
setup_logging
(
path
=
get_path
(
'
logging.json
'
))
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
self
.
assertEqual
(
logger
.
root
.
level
,
logging
.
DEBUG
)
self
.
assertEqual
(
logger
.
root
.
level
,
logging
.
DEBUG
)
def
test_setup_yaml
(
self
):
def
test_setup_yaml
(
self
):
log
.
setup_logging
(
default_
path
=
get_path
(
'
logging.yaml
'
))
log
.
setup_logging
(
path
=
get_path
(
'
logging.yaml
'
))
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
self
.
assertEqual
(
logger
.
root
.
level
,
logging
.
DEBUG
)
self
.
assertEqual
(
logger
.
root
.
level
,
logging
.
DEBUG
)
def
test_setup
(
self
):
def
test_setup
(
self
):
log
.
setup_logging
()
log
.
setup_logging
(
path
=
''
)
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
self
.
assertEqual
(
logger
.
root
.
level
,
logging
.
INFO
)
self
.
assertEqual
(
logger
.
root
.
level
,
logging
.
INFO
)
...
...
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