mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-09-20 22:37:44 +00:00
Replace root logger calls with module-specific loggers
This commit is contained in:
@@ -5,6 +5,8 @@ import time
|
||||
import diskcache
|
||||
from cachetools import TTLCache
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class LiveDataCache:
|
||||
"""Cache for spots and alerts. Uses the fast in-memory TTLCache for normal data I/O, including the TTL to enforce
|
||||
@@ -34,7 +36,7 @@ class LiveDataCache:
|
||||
try:
|
||||
callback(value)
|
||||
except Exception:
|
||||
logging.exception(f"Listener raised an exception for key {key}")
|
||||
logger.exception(f"Listener raised an exception for key {key}")
|
||||
|
||||
def get(self, key, default=None):
|
||||
with self._lock:
|
||||
@@ -70,7 +72,7 @@ class LiveDataCache:
|
||||
try:
|
||||
self._disk_cache.set("snapshot", data)
|
||||
except Exception as e:
|
||||
logging.exception(f"Failed to write snapshot to {self._snapshot_dir}")
|
||||
logger.exception(f"Failed to write snapshot to {self._snapshot_dir}")
|
||||
|
||||
def _load_snapshot(self):
|
||||
data = self._disk_cache.get("snapshot")
|
||||
@@ -83,7 +85,7 @@ class LiveDataCache:
|
||||
# Only restore entries that would still be within TTL
|
||||
if now - saved_at < self._ttl:
|
||||
self._cache[key] = value
|
||||
logging.info(f"Loaded snapshot from {self._snapshot_dir}")
|
||||
logger.info(f"Loaded snapshot from {self._snapshot_dir}")
|
||||
|
||||
def _start_periodic_snapshot(self, interval):
|
||||
def loop():
|
||||
|
||||
Reference in New Issue
Block a user