Remove logger from dataset, it's not necessary, as there's only one call location that wants to say something. Turn that into an exception instead

This commit is contained in:
Pim van Pelt
2021-09-15 07:56:50 +00:00
parent 610d03a14b
commit 09a2b6e9e4

View File

@ -8,19 +8,13 @@ from __future__ import (
import time import time
import agentx import agentx
import logging
class NullHandler(logging.Handler):
def emit(self, record):
pass
class DataSetError(Exception):
pass
class DataSet(): class DataSet():
def __init__(self): def __init__(self):
self._data = {} self._data = {}
self.logger = logging.getLogger('agentx.dataset')
self.logger.addHandler(NullHandler())
def set(self, oid, oid_type, value): def set(self, oid, oid_type, value):
if oid_type.startswith('int'): if oid_type.startswith('int'):
@ -42,7 +36,7 @@ class DataSet():
elif oid_type == 'counter64' or oid_type == 'uint64' or oid_type == 'u64': elif oid_type == 'counter64' or oid_type == 'uint64' or oid_type == 'u64':
t = agentx.TYPE_COUNTER64 t = agentx.TYPE_COUNTER64
else: else:
self.logger.error('Invalid oid_type: %s' % (oid_type)) raise DataSetErrror('Invalid oid_type: %s' % (oid_type))
return return
self._data[oid] = { self._data[oid] = {