fix: add bot name to stream_audio log lines
Multi-bot setups need to know which bot is streaming. Prefixes all stream_audio log messages with [username] for clarity. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -720,8 +720,8 @@ class MumbleBot:
|
||||
pass
|
||||
|
||||
_get_vol = volume if callable(volume) else lambda: volume
|
||||
log.info("stream_audio: starting pipeline for %s (vol=%.0f%%, seek=%.1fs)",
|
||||
url, _get_vol() * 100, seek)
|
||||
log.info("stream_audio: [%s] starting pipeline for %s (vol=%.0f%%, seek=%.1fs)",
|
||||
self._username, url, _get_vol() * 100, seek)
|
||||
|
||||
def _build_cmd(seek_pos):
|
||||
seek_flag = f" -ss {seek_pos:.3f}" if seek_pos > 0 else ""
|
||||
@@ -817,15 +817,17 @@ class MumbleBot:
|
||||
if not self._is_audio_ready():
|
||||
# Disconnected -- keep reading ffmpeg at real-time pace
|
||||
if _was_feeding:
|
||||
log.warning("stream_audio: connection lost, "
|
||||
"dropping frames at %d", frames)
|
||||
log.warning("stream_audio: [%s] connection lost, "
|
||||
"dropping frames at %d",
|
||||
self._username, frames)
|
||||
_was_feeding = False
|
||||
await asyncio.sleep(0.02)
|
||||
continue
|
||||
|
||||
if not _was_feeding:
|
||||
log.info("stream_audio: connection restored, "
|
||||
"resuming feed at frame %d", frames)
|
||||
log.info("stream_audio: [%s] connection restored, "
|
||||
"resuming feed at frame %d",
|
||||
self._username, frames)
|
||||
_was_feeding = True
|
||||
|
||||
# Seek: fade-out in progress
|
||||
@@ -893,7 +895,8 @@ class MumbleBot:
|
||||
continue
|
||||
|
||||
if frames == 1:
|
||||
log.info("stream_audio: first frame fed to pymumble")
|
||||
log.info("stream_audio: [%s] first frame fed to pymumble",
|
||||
self._username)
|
||||
|
||||
# Keep buffer at most 1 second ahead
|
||||
try:
|
||||
@@ -910,7 +913,8 @@ class MumbleBot:
|
||||
await asyncio.sleep(0.1)
|
||||
except (TypeError, AttributeError):
|
||||
pass
|
||||
log.info("stream_audio: finished, %d frames", frames)
|
||||
log.info("stream_audio: [%s] finished, %d frames",
|
||||
self._username, frames)
|
||||
except asyncio.CancelledError:
|
||||
# Only clear the buffer if volume is still audible -- if a
|
||||
# fade-out has already driven _cur_vol to ~0 the remaining
|
||||
@@ -921,11 +925,12 @@ class MumbleBot:
|
||||
self._mumble.sound_output.clear_buffer()
|
||||
except Exception:
|
||||
pass
|
||||
log.info("stream_audio: cancelled at frame %d (vol=%.3f)",
|
||||
frames, _cur_vol)
|
||||
log.info("stream_audio: [%s] cancelled at frame %d (vol=%.3f)",
|
||||
self._username, frames, _cur_vol)
|
||||
raise
|
||||
except Exception:
|
||||
log.exception("stream_audio: error at frame %d", frames)
|
||||
log.exception("stream_audio: [%s] error at frame %d",
|
||||
self._username, frames)
|
||||
raise
|
||||
finally:
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user