chilly-plumber-14235
10/13/2025, 1:06 PMtall-airline-16756
10/13/2025, 1:06 PMtall-airline-16756
10/13/2025, 1:07 PMuser_input_transcribed event to capture and log what the user says. This event gives you a transcript object that you can easily save to a file or database.
• For instance, you might write the user input to a file along with timestamps by using event-driven handlers.
Capturing Real-Time Model Output:
• The model’s outputs, both text and audio, are streamed through specific channels like text_ch and audio_ch. These channels send partial text tokens and audio frames as they happen.
• You can log these outputs to files, databases, or even external systems while they’re being generated.
Metrics and Telemetry:
• LiveKit also offers structured metrics for things like input/output token usage, latency, and overall performance through events such as usageEvent and AgentSession metrics.
• Plus, if you want to get deeper insights, OpenTelemetry integration can help you trace the entire execution flow and keep an eye on performance.
If you’d like, I’m here to provide more details or specific examples to help you implement this smoothly—just let me know!
Sources: basics/interrupts_user.py | livekit-agents/livekit/agents/metrics/base.py | Logs, metrics, and telemetry | LiveKit Docschilly-plumber-14235
10/13/2025, 1:15 PMtall-airline-16756
10/13/2025, 1:15 PMuser_input_transcribed and `text_ch`:
Logging `user_input_transcribed`:
async def on_transcription(transcript: str):
with open("user_speech_log.txt", "a") as f:
timestamp = datetime.now().strftime("[%Y-%m-%d %H:%M:%S]")
f.write(f"{timestamp} {transcript}\n")
This function helps you save the transcribed user input into a file, along with a timestamp to keep everything organized.
Logging text_ch (Model Output):
async def log_model_output(gen):
async for text in gen.text_ch:
with open("model_output_log.txt", "a") as f:
timestamp = datetime.now().strftime("[%Y-%m-%d %H:%M:%S]")
f.write(f"{timestamp} {text}\n")
This function captures the model’s real-time text output and logs it with timestamps, so you can easily track what’s happening.
Please feel free to reach out if you'd like me to walk you through this further or provide more examples—I’m here to help!chilly-plumber-14235
10/13/2025, 1:16 PMtall-airline-16756
10/13/2025, 1:16 PM/home/user/project, you’ll find the files user_speech_log.txt and model_output_log.txt created right there in that folder.
If you'd like to save these files somewhere else, no worries! You can simply provide an absolute path in the file name. For example:
with open("/path/to/your/directory/user_speech_log.txt", "a") as f:
Please feel free to reach out if you'd like a hand with setting up a custom file path—I’m here to help!chilly-plumber-14235
10/13/2025, 1:17 PMtall-airline-16756
10/13/2025, 1:17 PMlk agent logs --id <agent-id> --log-type deploy
• And to check out the build logs for your deployed version, try:
lk agent logs --id <agent-id> --log-type build
Forwarding Logs to External Services:
• You can set up integrations with services like Datadog, CloudWatch, Sentry, or New Relic by adding the right secrets (for example, DATADOG_TOKEN, AWS_ACCESS_KEY_ID).
• Once that’s all set, your runtime logs will be forwarded automatically for easy long-term storage and analysis.
If you’d like, I’m here to help you with setting up log forwarding or navigating the CLI—just let me know!
Sources: Log collection | LiveKit Docs