I am working on the logging aspect in Tango. I have used both Tango Logging Service (for viewing logs) and Python logging (for syslog storage). But to achieve this, I need to write two statements in the device server code using both services like:
Similarly for other levels (DEBUG, INFO, ERROR, WARN).
The intention is to merge the two logging services. That is, establishing one logging channel, either Tango or Python to log into different targets (Tango device and syslog).
Example:
self.fatal_stream("%s", logmsg)
should send messages to both syslog and logviewer.
I explored some alternatives. Like Python Log Viewer (2011 version), that displays logs and also filters logs on the basis of different levels. I have been going through these links and trying to explore more. The idea behind using this, is that, if we use Python logging for syslog and Python log viewer for viewing, our both purposes might be fulfilled without writing statements for two services separately.
The other alternative is adding syslog as a target in TLS apart from file, console and device.
Let me know, in case anyone has tried it before, and, whether it is a right approach to move forward.
Also, I wanted to know:
Has Tango community already planned to update Tango Logging Service with additional features in next release (v10) ?
If we opt for modifying the existing Tango logging service to include syslog as an additional target, how should we go for it?
As far as I remember, there is nothing big planned for the moment on that topic… but contributions and ideas are of course welcome.
Log4Tango was originally based on log4cpp project.
I noticed there seems to be already a special appender (RemoteSyslogAppender) for syslogs in log4cpp project.
It might be interesting to have a look at it and see whether we could integrate it and adapt it into our cppTango project where log4tango code is currently stored.
It looks like this RemoteSyslogAppender was already existing in the log4cpp version which was used to build log4tango but it seems this appender has been removed. I don’t know why. Maybe one of the dinosaurs or great archeologist from our community knows why?
In order to solve the problem without having to wait for someone to reinject the RemoteSyslogAppender into Tango, you could write a python logging handler forwarding your logging events to the TLS. All you need is a handler owning a reference to your tango device (or simply to its logger - in case PyTango exposes it).
BTW, we decided to remove most of the log4cpp appenders cause our design dogma was 100% Tango centric - any single byte exchanged between two Tango entities was supposed to be carried by the Tango protocol. It was also a way to lighten the dependency. However, it should not be a big deal to add the RemoteSyslogAppender back to log4tango.
Lochan,
I didn’t clearly explain my proposal. What I propose is to write your own Python handler - i.e. to implement a TangoHandler class inheriting from Python logging.Handler. You have to __init__ialize your TangoHandler instance passing a reference to your Tango device and you’re almost done - i.e. in TangoHandler.emit just forward the log record to the TLS.
See https://dzone.com/articles/python-custom-logging-handler-example for an example.
n.
You can talk to any device from python whichever is its implementation language
However, reading your last question I have a doubt about my understanding of your use case…
Hope everything is clear on your side