From: Uwe Hermann Date: Fri, 19 Apr 2013 11:15:51 +0000 (+0200) Subject: python: Add a Log class to control libsigrok logging. X-Git-Tag: dsupstream~99 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=816aed6c9157721c7123f1f29fe01f353278af22;p=libsigrok.git python: Add a Log class to control libsigrok logging. --- diff --git a/bindings/python/sigrok/core/classes.py b/bindings/python/sigrok/core/classes.py index e51f33a6..89049cc4 100644 --- a/bindings/python/sigrok/core/classes.py +++ b/bindings/python/sigrok/core/classes.py @@ -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):