How to retrieve a device logging level within a device server

Hi there,

Is it possible to retrieve a device logging level within a device server?
Device_4Impl does not seem to provide such a facility.

Thanks for your help.
Cyrille.
Hi Cyrille,

One way to do that is to create a DeviceProxy on yourself and to invoke Tango::DeviceProxy::get_logging_level() as documented here :
http://www.esrf.eu/computing/cs/tango/tango_doc/kernel_doc/cpp_doc/classTango_1_1DeviceProxy.html#a7bed3468688fb6b52cb6ce398effdc51

Another way would be to invoke GetLoggingLevel Tango command on your admin device but this is a bit more complicated.

Hoping this helps,
Reynald
Rosenberg's Law: Software is easy to make, except when you want it to do something new.
Corollary: The only software that's worth making is software that does something new.
Hi Cyrille,

You can get the device logging level using admin device. Create a DeviceProxy of the admin device within your device and retrieve the logging level using "GetLoggingLevel" command exposed by the admin device.

For details, refer section 6.1.7.2 of Tango Manual 9.2

Hope it helps.

Edit: Thanks Reynald, I missed to see your post and the first solution which you proposed. smile

Kind regards,
Jyotin
Edited 7 years ago
Hi,

thanks for your answers! I cannot use device proxy on itself nor admin device as I try to get logging level at init_device time…
I found an interesting link http://www.tango-controls.org/resources/howto/how-pytango/ and especially the following:

"Get the device server admin

NOT TESTED

U = PyTango.Util.instance()
U.get_dserver_device()

Modify internal polling

NOTE: It doesn't work at init_device(); must be done later on in a hook method"

I don't understand what "must be done later on in a hook method" means. Can someone help?

Cyrille.
Hi Cyrille,

A possible way of doing it in Java.

In the init_device method use the following code:

String devName = deviceManager.getName();
int currLogLevel = LoggingManager.getInstance().getLoggingLevel(devName);

Hope this helps.

Vatsal Trivedi
Edited 7 years ago
Hi there,

Thanks a lot for the last answer. It helped me a lot indeed!

Using PyTango, if you need to get the current logging level at init_device time, do the following:

    def init_device(self):
        self.debug_stream("In init_device()")
        self.get_device_properties(self.get_device_class())
        #—– PROTECTED REGION ID(MyDevice.init_device) ENABLED START —–#
        level = self.get_logger().get_level()
        #—– PROTECTED REGION END —–# // MyDevice.init_device

level will have one of the following values :
OFF = 100
FATAL = 200
ERROR = 300
WARN = 400
INFO = 500
DEBUG = 600

Cyrille.
Hi Cyrille,

I am not the Python expert; however tried to implement the use case you mentioned.
You can get device logging level by using below code in the init method:

    def __init__(self, cl, name):
        PyTango.Device_4Impl.__init__(self,cl,name)
        self.debug_stream("In __init__()")
        LoggingLevelTest.init_device(self)
        #—– PROTECTED REGION ID(LoggingLevelTest.__init__) ENABLED START —–#

        print PyTango.Logger.get_level(self.get_logger())

        #—– PROTECTED REGION END —–#	//	LoggingLevelTest.__init__


Logging relation with the return values is as shown below:

100 - OFF (Log Level - 0)
200 - FATAL (Log Level - 1)
300 - ERROR (Log Level - 2)
400 - WARN (Log Level - 3)
500 - INFO (Log Level - 4)
600 - DEBUG (Log Level - 5)

Hope this is what you are looking for.

Kind regards,
Jyotin

Edit: I missed your post, great to see that you figured out the solution! smile
Edited 7 years ago
Thanks Jyotin.

Cyrille.
 
Register or login to create to post a reply.