Skip to content

Commit 100036d

Browse files
committed
Reduce the amount of logs
With a lot of configured cameras, logging the status every second fills up the logs quite fast without actually logging much useful information. This patch banishes most of these logs to the debug logs. Only on every full minute is the status still being logged as an info level log.
1 parent 96a71ba commit 100036d

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

occameracontrol/camera.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,15 @@ def update_position(self):
106106
agent_id = self.agent.agent_id
107107
event = self.agent.next_event()
108108

109+
level = logging.DEBUG if int(time.time()) % 60 else logging.INFO
109110
if event.future():
110-
logger.info('[%s] Next event `%s` starts in %i seconds',
111-
agent_id, event.title, event.start - time.time())
111+
logger.log(level, '[%s] Next event `%s` starts in %i seconds',
112+
agent_id, event.title[:40], event.start - time.time())
112113
elif event.active():
113-
logger.info('[%s] Active event `%s` ends in %i seconds',
114-
agent_id, event.title, event.end - time.time())
114+
logger.log(level, '[%s] Active event `%s` ends in %i seconds',
115+
agent_id, event.title[:40], event.end - time.time())
115116
else:
116-
logger.info('[%s] No planned events', agent_id)
117+
logger.log(level, '[%s] No planned events', agent_id)
117118

118119
if event.active():
119120
if self.position != self.preset_active:

0 commit comments

Comments
 (0)