Hi avoinemt,
By default, the logging module is not part of the Dia framework. You can add the module to the Dia framework by adding it to a location it knows about.
For instance, I copied the logging module into the lib/ directory, so my source tree would look like /src/lib/logging/.
Then you can import it from a device/presentation/logger like: ‘import lib.logging as logging’, and use it normally afterwards. When you go to use ‘make.py’ on the configuration file, you can investigate that the dia.zip has a lib/logging/ directory populated with the modules you used.
Here is a incredibly basic device driver that I did this to, just to see what would happen:
imports
from devices.device_base import DeviceBase
from settings.settings_base import SettingsBase, Setting
from channels.channel_source_device_property import *
import lib.logging as logging
constants
exception classes
interface functions
classes
#Null device is meant for testing purposes only and serves as an example
#device
class LogDevice(DeviceBase):
“”"
This class extends one of our base classes and is intended as an
example of a concrete, example implementation, but it is not itself
meant to be included as part of our developer API. Please consult the
base class documentation for the API and the source code for this file
for an example implementation.
"""
def __init__(self, name, core_services):
self.__name = name
self.__core = core_services
## Settings Table Definition:
settings_list = [
]
## Channel Properties Definition:
property_list = [
]
## Initialize the Devicebase interface:
DeviceBase.__init__(self, self.__name, self.__core,
settings_list, property_list)
## Functions which must be implemented to conform to the DeviceBase
## interface:
def apply_settings(self):
SettingsBase.merge_settings(self)
accepted, rejected, not_found = SettingsBase.verify_settings(self)
SettingsBase.commit_settings(self, accepted)
return (accepted, rejected, not_found)
def start(self):
log = logging.getLogger('Mylogger')
handler = logging.StreamHandler()
log.addHandler(handler)
log.warn('Hello, this is a test.')
return True
def stop(self):
return True
Hope this helps!
Max