Move all loggers to be members of the class, not global objects

This commit is contained in:
Pim van Pelt
2021-09-12 16:08:35 +00:00
parent 9265e211e3
commit 7206d92f40
5 changed files with 57 additions and 79 deletions

View File

@ -6,7 +6,8 @@ from __future__ import (
print_function,
)
# --------------------------------------------
import time
import agentx
import logging
@ -15,17 +16,11 @@ class NullHandler(logging.Handler):
pass
logger = logging.getLogger('agentx.dataset')
logger.addHandler(NullHandler())
# --------------------------------------------
import time
import agentx
class DataSet():
def __init__(self):
self._data = {}
self.logger = logging.getLogger('agentx.dataset')
self.logger.addHandler(NullHandler())
def set(self, oid, oid_type, value):
if oid_type.startswith('int'):
@ -47,7 +42,7 @@ class DataSet():
elif oid_type == 'counter64' or oid_type == 'uint64' or oid_type == 'u64':
t = agentx.TYPE_COUNTER64
else:
logger.error('Invalid oid_type: %s' % (oid_type))
self.logger.error('Invalid oid_type: %s' % (oid_type))
return
self._data[oid] = {