Skip to content

Commit

Permalink
Changed Objectstore log to debug
Browse files Browse the repository at this point in the history
This should help silence the log a bit.
  • Loading branch information
hemna committed Feb 4, 2025
1 parent ef670b6 commit 164932b
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions aprsd/utils/objectstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@

from oslo_config import cfg


CONF = cfg.CONF
LOG = logging.getLogger("APRSD")
LOG = logging.getLogger('APRSD')


class ObjectStoreMixin:
Expand Down Expand Up @@ -63,7 +62,7 @@ def _init_store(self):
def _save_filename(self):
save_location = CONF.save_location

return "{}/{}.p".format(
return '{}/{}.p'.format(
save_location,
self.__class__.__name__.lower(),
)
Expand All @@ -75,13 +74,13 @@ def save(self):
self._init_store()
save_filename = self._save_filename()
if len(self) > 0:
LOG.info(
f"{self.__class__.__name__}::Saving"
f" {len(self)} entries to disk at "
f"{save_filename}",
LOG.debug(
f'{self.__class__.__name__}::Saving'
f' {len(self)} entries to disk at '
f'{save_filename}',
)
with self.lock:
with open(save_filename, "wb+") as fp:
with open(save_filename, 'wb+') as fp:
pickle.dump(self.data, fp)
else:
LOG.debug(
Expand All @@ -97,21 +96,21 @@ def load(self):
return
if os.path.exists(self._save_filename()):
try:
with open(self._save_filename(), "rb") as fp:
with open(self._save_filename(), 'rb') as fp:
raw = pickle.load(fp)
if raw:
self.data = raw
LOG.debug(
f"{self.__class__.__name__}::Loaded {len(self)} entries from disk.",
f'{self.__class__.__name__}::Loaded {len(self)} entries from disk.',
)
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:
LOG.error(f"Failed to UnPickle {self._save_filename()}")
LOG.error(f'Failed to UnPickle {self._save_filename()}')
LOG.error(ex)
self.data = {}
else:
LOG.debug(f"{self.__class__.__name__}::No save file found.")
LOG.debug(f'{self.__class__.__name__}::No save file found.')

def flush(self):
"""Nuke the old pickle file that stored the old results from last aprsd run."""
Expand Down

0 comments on commit 164932b

Please sign in to comment.