Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pycalibration
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Analyze
Contributor 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
calibration
pycalibration
Commits
d1708a78
Commit
d1708a78
authored
5 months ago
by
Karim Ahmed
Browse files
Options
Downloads
Patches
Plain Diff
fix: fix bug of missing exc_info, remove info and put back console handler for report display
parent
906c4b04
No related branches found
No related tags found
1 merge request
!1059
[webservice] Intoduce Global Logger for xfel-calibrate
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/xfel_calibrate/setup_logging.py
+10
-6
10 additions, 6 deletions
src/xfel_calibrate/setup_logging.py
with
10 additions
and
6 deletions
src/xfel_calibrate/setup_logging.py
+
10
−
6
View file @
d1708a78
...
@@ -27,9 +27,9 @@ class CustomJsonFormatter(jsonlogger.JsonFormatter):
...
@@ -27,9 +27,9 @@ class CustomJsonFormatter(jsonlogger.JsonFormatter):
log_record
[
'
lineno
'
]
=
record
.
lineno
log_record
[
'
lineno
'
]
=
record
.
lineno
log_record
[
'
class
'
]
=
getattr
(
record
,
'
class
'
,
'
DefaultClass
'
)
log_record
[
'
class
'
]
=
getattr
(
record
,
'
class
'
,
'
DefaultClass
'
)
# Get the full class hierarchy
exc_info
=
getattr
(
record
,
'
exc_info
'
,
None
)
exc_
class
=
getattr
(
record
,
'
exc_info
'
,
(
None
,
None
,
None
))
[
0
]
if
exc_
info
and
exc_info
[
0
]
:
if
exc_class
:
exc_class
=
exc_info
[
0
]
class_hierarchy
=
[]
class_hierarchy
=
[]
current_class
=
exc_class
current_class
=
exc_class
while
current_class
and
current_class
!=
Exception
:
while
current_class
and
current_class
!=
Exception
:
...
@@ -66,7 +66,11 @@ def create_job_specific_handler(log_level, file_suffix):
...
@@ -66,7 +66,11 @@ def create_job_specific_handler(log_level, file_suffix):
# Create job-specific file handlers
# Create job-specific file handlers
error_handler
=
create_job_specific_handler
(
logging
.
ERROR
,
'
errors
'
)
error_handler
=
create_job_specific_handler
(
logging
.
ERROR
,
'
errors
'
)
warning_handler
=
create_job_specific_handler
(
logging
.
WARNING
,
'
warnings
'
)
warning_handler
=
create_job_specific_handler
(
logging
.
WARNING
,
'
warnings
'
)
info_handler
=
create_job_specific_handler
(
logging
.
INFO
,
'
info
'
)
# Keep console handler for notebook and slurm.out stdout
console_handler
=
logging
.
StreamHandler
()
console_handler
.
setLevel
(
logging
.
INFO
)
# Avoid errors being logged in warnings.json
# Avoid errors being logged in warnings.json
warning_handler
.
addFilter
(
lambda
record
:
record
.
levelno
<
logging
.
ERROR
)
warning_handler
.
addFilter
(
lambda
record
:
record
.
levelno
<
logging
.
ERROR
)
...
@@ -75,12 +79,12 @@ warning_handler.addFilter(lambda record: record.levelno < logging.ERROR)
...
@@ -75,12 +79,12 @@ warning_handler.addFilter(lambda record: record.levelno < logging.ERROR)
context_filter
=
ContextFilter
()
context_filter
=
ContextFilter
()
error_handler
.
addFilter
(
context_filter
)
error_handler
.
addFilter
(
context_filter
)
warning_handler
.
addFilter
(
context_filter
)
warning_handler
.
addFilter
(
context_filter
)
info
_handler
.
addFilter
(
context_filter
)
console
_handler
.
addFilter
(
context_filter
)
# Add handlers to logger
# Add handlers to logger
logger
.
addHandler
(
error_handler
)
logger
.
addHandler
(
error_handler
)
logger
.
addHandler
(
warning_handler
)
logger
.
addHandler
(
warning_handler
)
logger
.
addHandler
(
info
_handler
)
logger
.
addHandler
(
console
_handler
)
handling_error
=
False
handling_error
=
False
...
...
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