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
12b7195d
Commit
12b7195d
authored
3 years ago
by
Jan David Mol
Browse files
Options
Downloads
Patches
Plain Diff
Add example log rerouting to Kibana (and Python) to SDP device
parent
a2e7d5f5
No related branches found
No related tags found
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
+11
-1
11 additions, 1 deletion
SDP/SDP/SDP.py
SDP/SDP/lofar_logging.py
+29
-0
29 additions, 0 deletions
SDP/SDP/lofar_logging.py
with
40 additions
and
1 deletion
SDP/SDP/SDP.py
+
11
−
1
View file @
12b7195d
...
...
@@ -26,10 +26,11 @@ import numpy
from
wrappers
import
only_in_states
,
only_when_on
,
fault_on_error
from
opcua_connection
import
OPCUAConnection
from
lofar_logging
import
PythonLoggingMixin
__all__
=
[
"
SDP
"
,
"
main
"
]
class
SDP
(
Device
):
class
SDP
(
Device
,
PythonLoggingMixin
):
"""
**Properties:**
...
...
@@ -485,4 +486,13 @@ def main(args=None, **kwargs):
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
()
This diff is collapsed.
Click to expand it.
SDP/SDP/lofar_logging.py
0 → 100644
+
29
−
0
View file @
12b7195d
import
logging
def
configured_logger
(
name
=
''
):
logger
=
logging
.
getLogger
(
name
)
logger
.
setLevel
(
logging
.
DEBUG
)
try
:
from
logstash_async.handler
import
AsynchronousLogstashHandler
logger
.
addHandler
(
AsynchronousLogstashHandler
(
"
elk
"
,
5959
,
database_path
=
'
logstash_test.db
'
))
except
Exception
:
logger
.
exception
(
"
Cannot import or configure logstash_async module, not forwarding logs to ELK stack.
"
)
return
logger
logger
=
configured_logger
()
class
PythonLoggingMixin
(
object
):
"""
Also inherit this class to have your Tango Device log to python instead.
"""
# Monkey patch the python logger to replace the tango logger
debug_stream
=
logger
.
debug
info_stream
=
logger
.
info
warn_stream
=
logger
.
warning
warning_stream
=
logger
.
warning
error_stream
=
logger
.
error
fatal_stream
=
logger
.
fatal
critical_stream
=
logger
.
critical
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