whitphx / streamlit-webrtc

Real-time video and audio processing on Streamlit
https://discuss.streamlit.io/t/new-component-streamlit-webrtc-a-new-way-to-deal-with-real-time-media-streams/8669
MIT License
1.4k stars 188 forks source link

Setting Log Level #752

Closed alercelik closed 2 years ago

alercelik commented 2 years ago

Hello, how can I set log level? I want to set it to WARNING for this library and INFO for my own program.

whitphx commented 2 years ago

This library uses a logger with name streamlit_webrtc or its child loggers. The code below is a sample to get the logger and set the log level. https://github.com/whitphx/streamlit-webrtc/blob/b80878229378a090510851f32c400234da60523b/app.py#L684-L685

whitphx commented 2 years ago

Ah, aiortc, a library streamlit-webrtc is using inside it, also has its logger with a different namespace. So if you want to set the log level as warning on both loggers, the code below would be the sample.

st_webrtc_logger = logging.getLogger("streamlit_webrtc")
st_webrtc_logger.setLevel(logging.WARNING)

aioice_logger = logging.getLogger("aioice")
aioice_logger.setLevel(logging.WARNING)
whitphx commented 2 years ago

Added the "logging" section in README: https://github.com/whitphx/streamlit-webrtc#logging