]> sigrok.org Git - libsigrok.git/commitdiff
python: Add a Log class to control libsigrok logging.
authorUwe Hermann <redacted>
Fri, 19 Apr 2013 11:15:51 +0000 (13:15 +0200)
committerUwe Hermann <redacted>
Fri, 19 Apr 2013 11:15:51 +0000 (13:15 +0200)
bindings/python/sigrok/core/classes.py

index e51f33a6a35d18f87f7ac8f74f2e76791adb2865..89049cc4a15b94f993209fd6e196ff84260ad632 100644 (file)
@@ -23,7 +23,7 @@ from .lowlevel import *
 from . import lowlevel
 import itertools
 
-__all__ = ['Error', 'Context', 'Driver', 'Device', 'Session', 'Packet']
+__all__ = ['Error', 'Context', 'Driver', 'Device', 'Session', 'Packet', 'Log']
 
 class Error(Exception):
 
@@ -275,6 +275,31 @@ class Analog(object):
             self._data = float_array.frompointer(self.struct.data)
         return self._data
 
+class Log(object):
+
+    NONE = SR_LOG_NONE
+    ERR = SR_LOG_ERR
+    WARN = SR_LOG_WARN
+    INFO = SR_LOG_INFO
+    DBG = SR_LOG_DBG
+    SPEW = SR_LOG_SPEW
+
+    @property
+    def level(self):
+        return sr_log_loglevel_get()
+
+    @level.setter
+    def level(self, l):
+        check(sr_log_loglevel_set(l))
+
+    @property
+    def domain(self):
+        return sr_log_logdomain_get()
+
+    @domain.setter
+    def domain(self, d):
+        check(sr_log_logdomain_set(d))
+
 for symbol_name in dir(lowlevel):
     prefix = 'SR_DF_'
     if symbol_name.startswith(prefix):