Documentation
¶
Overview ¶
Package logstream renders a bounded, scrollable log view. Entries are color-coded by level. The view sticks to the tail like `tail -f` unless the user scrolls up; new entries appended while scrolled up do not jump the viewport.
Index ¶
- type Entry
- type Level
- type Stream
- func (s Stream) Append(e Entry) Stream
- func (s Stream) Clear() Stream
- func (s Stream) Entries() []Entry
- func (s Stream) Init() tea.Cmd
- func (s Stream) Offset() int
- func (s Stream) TotalLines() int
- func (s Stream) Update(msg tea.Msg) (Stream, tea.Cmd)
- func (s Stream) View() string
- func (s Stream) WithCapacity(n int) Stream
- func (s Stream) WithMinLevel(l Level) Stream
- func (s Stream) WithSize(w, h int) Stream
- func (s Stream) WithTimeFormat(f string) Stream
- func (s Stream) WithTimestamps(show bool) Stream
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Entry ¶
type Entry struct {
Time time.Time
Level Level
Source string // optional component / module name
Message string
}
Entry is one log line.
type Stream ¶
type Stream struct {
// contains filtered or unexported fields
}
Stream is a Bubble Tea model that renders a windowed view of entries.
func (Stream) Append ¶
Append adds an entry. If the buffer exceeds capacity, the oldest drops. If the viewport is at the tail (offset == 0), it stays at the tail. Otherwise the offset is preserved so the user sees the same content.
func (Stream) TotalLines ¶
TotalLines is the count of post-wrap lines currently in the buffer after level filtering.
func (Stream) Update ¶
Update handles scroll keys. Up/Down moves one line, PgUp/PgDn moves a window, Home jumps to the top of buffered history, End returns to tail.
func (Stream) View ¶
View renders the visible window. Lines below the tail are blank-padded to preserve the configured height.
func (Stream) WithCapacity ¶
WithCapacity caps the ring buffer. When exceeded, oldest entries drop. Minimum capacity is 1.
func (Stream) WithMinLevel ¶
WithMinLevel drops entries below the given severity from the view. The underlying ring is unchanged.
func (Stream) WithTimeFormat ¶
WithTimeFormat overrides the timestamp format. Default is "15:04:05".
func (Stream) WithTimestamps ¶
WithTimestamps toggles the leading timestamp column.
