1
0
mirror of https://github.com/craigerl/aprsd.git synced 2025-07-31 12:52:24 -04:00

Changed Objectstore log to debug

This should help silence the log a bit.
This commit is contained in:
Hemna 2025-02-04 10:34:05 -08:00
parent fd517b3218
commit 361663e7d2

View File

@ -6,9 +6,8 @@ import threading
from oslo_config import cfg from oslo_config import cfg
CONF = cfg.CONF CONF = cfg.CONF
LOG = logging.getLogger("APRSD") LOG = logging.getLogger('APRSD')
class ObjectStoreMixin: class ObjectStoreMixin:
@ -63,7 +62,7 @@ class ObjectStoreMixin:
def _save_filename(self): def _save_filename(self):
save_location = CONF.save_location save_location = CONF.save_location
return "{}/{}.p".format( return '{}/{}.p'.format(
save_location, save_location,
self.__class__.__name__.lower(), self.__class__.__name__.lower(),
) )
@ -75,13 +74,13 @@ class ObjectStoreMixin:
self._init_store() self._init_store()
save_filename = self._save_filename() save_filename = self._save_filename()
if len(self) > 0: if len(self) > 0:
LOG.info( LOG.debug(
f"{self.__class__.__name__}::Saving" f'{self.__class__.__name__}::Saving'
f" {len(self)} entries to disk at " f' {len(self)} entries to disk at '
f"{save_filename}", f'{save_filename}',
) )
with self.lock: with self.lock:
with open(save_filename, "wb+") as fp: with open(save_filename, 'wb+') as fp:
pickle.dump(self.data, fp) pickle.dump(self.data, fp)
else: else:
LOG.debug( LOG.debug(
@ -97,21 +96,21 @@ class ObjectStoreMixin:
return return
if os.path.exists(self._save_filename()): if os.path.exists(self._save_filename()):
try: try:
with open(self._save_filename(), "rb") as fp: with open(self._save_filename(), 'rb') as fp:
raw = pickle.load(fp) raw = pickle.load(fp)
if raw: if raw:
self.data = raw self.data = raw
LOG.debug( LOG.debug(
f"{self.__class__.__name__}::Loaded {len(self)} entries from disk.", f'{self.__class__.__name__}::Loaded {len(self)} entries from disk.',
) )
else: else:
LOG.debug(f"{self.__class__.__name__}::No data to load.") LOG.debug(f'{self.__class__.__name__}::No data to load.')
except (pickle.UnpicklingError, Exception) as ex: except (pickle.UnpicklingError, Exception) as ex:
LOG.error(f"Failed to UnPickle {self._save_filename()}") LOG.error(f'Failed to UnPickle {self._save_filename()}')
LOG.error(ex) LOG.error(ex)
self.data = {} self.data = {}
else: else:
LOG.debug(f"{self.__class__.__name__}::No save file found.") LOG.debug(f'{self.__class__.__name__}::No save file found.')
def flush(self): def flush(self):
"""Nuke the old pickle file that stored the old results from last aprsd run.""" """Nuke the old pickle file that stored the old results from last aprsd run."""