Skip to content

Commit

Permalink
fix(session): reduce verbosity by using debug level 4 (vs 3)
Browse files Browse the repository at this point in the history
Signed-off-by: Cedric Hombourger <[email protected]>
  • Loading branch information
chombourger committed Jan 16, 2025
1 parent 7f1852f commit 15c757c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
10 changes: 5 additions & 5 deletions mtda/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1571,7 +1571,7 @@ def load_www_config(self, parser):
self._www.configure(dict(parser.items('www')))

def notify(self, what, info):
self.mtda.debug(3, f"main.notify({what},{info})")
self.mtda.debug(4, f"main.notify({what},{info})")

result = None
if self.socket is not None:
Expand All @@ -1582,7 +1582,7 @@ def notify(self, what, info):
if self._www is not None:
self._www.notify(what, info)

self.mtda.debug(3, f"main.notify: {result}")
self.mtda.debug(4, f"main.notify: {result}")
return result

def start(self):
Expand Down Expand Up @@ -1732,7 +1732,7 @@ def stop(self):
self.socket = None

def session_event(self, info):
self.mtda.debug(3, f"main.session_event({info})")
self.mtda.debug(4, f"main.session_event({info})")

info = info.split()
event = info[0]
Expand Down Expand Up @@ -1764,7 +1764,7 @@ def session_event(self, info):
self.storage_close(None)

def _session_check(self, session=None):
self.mtda.debug(3, f"main._session_check({session})")
self.mtda.debug(4, f"main._session_check({session})")

result = None
if self._session_manager is not None:
Expand All @@ -1777,7 +1777,7 @@ def _session_check(self, session=None):
self.mtda.debug(2, "device powered down after "
f"{self._power_timeout} seconds of inactivity")

self.mtda.debug(3, f"main._session_check: {result}")
self.mtda.debug(4, f"main._session_check: {result}")
return result

def _check_locked(self, session):
Expand Down
26 changes: 13 additions & 13 deletions mtda/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def __init__(self, mtda, lock_timeout, session_timeout):
self._sessions = {}

def check(self, session=None):
self.mtda.debug(3, f"session.check({session})")
self.mtda.debug(4, f"session.check({session})")

events = []
now = time.monotonic()
Expand All @@ -45,7 +45,7 @@ def check(self, session=None):
inactive = []
for s in self._sessions:
left = self._sessions[s] - now
self.mtda.debug(3, "session %s: %d seconds" % (s, left))
self.mtda.debug(4, "session %s: %d seconds" % (s, left))
if left <= 0:
inactive.append(s)
for s in inactive:
Expand Down Expand Up @@ -73,11 +73,11 @@ def check(self, session=None):
for e in events:
self.notify(e)

self.mtda.debug(3, f"session.check: {result}")
self.mtda.debug(4, f"session.check: {result}")
return result

def lock(self, session):
self.mtda.debug(3, f"session.lock({session})")
self.mtda.debug(4, f"session.lock({session})")

self.check(session)
with self._lock:
Expand All @@ -88,7 +88,7 @@ def lock(self, session):
else:
result = False

self.mtda.debug(3, f"session.lock(): {result}")
self.mtda.debug(4, f"session.lock(): {result}")
return result

def locked(self, session):
Expand All @@ -100,7 +100,7 @@ def locked(self, session):
return result

def unlock(self, session):
self.mtda.debug(3, f"session.unlock({session})")
self.mtda.debug(4, f"session.unlock({session})")

result = False
self.check(session)
Expand All @@ -112,33 +112,33 @@ def unlock(self, session):
if result is True:
self.notify(f"UNLOCKED {session}")

self.mtda.debug(3, f"session.unlock: {result}")
self.mtda.debug(4, f"session.unlock: {result}")
return result

def notify(self, info):
self.mtda.debug(3, f"session.notify({info})")
self.mtda.debug(4, f"session.notify({info})")

result = None
if info is not None:
for m in self._monitors:
m.session_event(info)
self.mtda.notify(CONSTS.EVENTS.SESSION, info)

self.mtda.debug(3, f"session.notify: {result}")
self.mtda.debug(4, f"session.notify: {result}")
return result

def monitor(self, monitor):
self.mtda.debug(3, "session.monitor()")
self.mtda.debug(4, "session.monitor()")

result = None
with self._lock:
self._monitors.append(monitor)

self.mtda.debug(3, f"session.monitor: {result}")
self.mtda.debug(4, f"session.monitor: {result}")
return result

def set_timeout(self, timeout, session=None):
self.mtda.debug(3, f"session.set_timeout({timeout}, {session})")
self.mtda.debug(4, f"session.set_timeout({timeout}, {session})")

with self._lock:
result = self._session_timeout
Expand All @@ -150,5 +150,5 @@ def set_timeout(self, timeout, session=None):
self._sessions[s] = now + timeout
self.check(session)

self.mtda.debug(3, f"session.set_timeout: {result}")
self.mtda.debug(4, f"session.set_timeout: {result}")
return result

0 comments on commit 15c757c

Please sign in to comment.