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:
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
#Null device is meant for testing purposes only and serves as an example
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,
## Functions which must be implemented to conform to the DeviceBase
accepted, rejected, not_found = SettingsBase.verify_settings(self)
return (accepted, rejected, not_found)
log = logging.getLogger('Mylogger')
handler = logging.StreamHandler()
log.warn('Hello, this is a test.')
Hope this helps!