Tail -f sample.log like feature using SL

Summary

Just wondering if anyone can give any suggestions how to implement linux tail like feature for log file using SL.
Thanks

Steps to reproduce

Hi @Sai_SaiGraph

There’s a Python library called tailer that provides similar functionality as Linux’s tail.

A code snippet of using it is as follows:

# Get the last 3 lines of the file
tailer.tail(open('sample.log'), 3)
# ['Line 9', 'Line 10', 'Line 11']

Hope this helps!

Best regards,
Chanin

1 Like

Thanks Chanin could you provide a simple example of how to integrate with streamlit please.
Thanks
Sai

Here you are.

import streamlit as st
import tailer

for line in tailer.tail(open('sample.log'), 3):
    st.text(line)
2 Likes

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.