Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
tango
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira issues
Open Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
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
Code review analytics
Issue analytics
Insights
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
LOFAR2.0
tango
Commits
3f639daf
Commit
3f639daf
authored
3 years ago
by
Jan David Mol
Browse files
Options
Downloads
Patches
Plain Diff
Removed straying dev code, use our logging format
parent
e5f6d371
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!7
Resolve #2021 "03 16 branched from master elk stack"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
SDP/SDP/SDP.py
+0
-9
0 additions, 9 deletions
SDP/SDP/SDP.py
SDP/SDP/lofar_logging.py
+13
-0
13 additions, 0 deletions
SDP/SDP/lofar_logging.py
with
13 additions
and
9 deletions
SDP/SDP/SDP.py
+
0
−
9
View file @
3f639daf
...
@@ -489,13 +489,4 @@ def main(args=None, **kwargs):
...
@@ -489,13 +489,4 @@ def main(args=None, **kwargs):
if
__name__
==
'
__main__
'
:
if
__name__
==
'
__main__
'
:
x
=
Device
.
error_stream
def
new_error_stream
(
self
,
*
args
,
**
kwargs
):
print
(
"
logging to python
"
)
logger
.
error
(
*
args
,
**
kwargs
)
print
(
"
logging to tango
"
)
x
.
error_stream
(
self
,
*
args
,
**
kwargs
)
Device
.
error_stream
=
new_error_stream
main
()
main
()
This diff is collapsed.
Click to expand it.
SDP/SDP/lofar_logging.py
+
13
−
0
View file @
3f639daf
import
logging
import
logging
from
functools
import
wraps
from
functools
import
wraps
# Always also log the hostname because it makes the origin of the log clear.
import
socket
hostname
=
socket
.
gethostname
()
def
configure_logger
(
logger
:
logging
.
Logger
,
log_extra
=
None
):
def
configure_logger
(
logger
:
logging
.
Logger
,
log_extra
=
None
):
logger
.
setLevel
(
logging
.
DEBUG
)
logger
.
setLevel
(
logging
.
DEBUG
)
...
@@ -16,6 +20,15 @@ def configure_logger(logger: logging.Logger, log_extra=None):
...
@@ -16,6 +20,15 @@ def configure_logger(logger: logging.Logger, log_extra=None):
# install the handler
# install the handler
logger
.
addHandler
(
handler
)
logger
.
addHandler
(
handler
)
# for now, also log to stderr
# Set up logging in a way that it can be understood by a human reader, be
# easily grep'ed, be parsed with a couple of shell commands and
# easily fed into an Kibana/Elastic search system.
handler
=
logging
.
StreamHandler
()
formatter
=
logging
.
Formatter
(
fmt
=
'
%(asctime)s.%(msecs)d %(levelname)s - HOST=
"
{}
"
PID=
"
%(process)d
"
TNAME=
"
%(threadName)s
"
TID=
"
%(thread)d
"
FILE=
"
%(pathname)s
"
LINE=
"
%(lineno)d
"
FUNC=
"
%(funcName)s
"
MSG=
"
%(message)s
"'
.
format
(
hostname
),
datefmt
=
'
%Y-%m-%dT%H:%M:%S
'
)
handler
.
setFormatter
(
formatter
)
logger
.
addHandler
(
handler
)
except
Exception
:
except
Exception
:
logger
.
exception
(
"
Cannot import or configure logstash_async module, not forwarding logs to ELK stack.
"
)
logger
.
exception
(
"
Cannot import or configure logstash_async module, not forwarding logs to ELK stack.
"
)
...
...
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