webtail

package
v0.0.0-...-6ed5ca5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 20, 2025 License: Apache-2.0 Imports: 16 Imported by: 0

README

Make HTTP Handler

import (
	"github.com/OutOfBedlam/webterm"
	"github.com/OutOfBedlam/webterm/webtail"
)

mux := http.NewServeMux()
mux.Handle("/web/logs/", makeTail("/web/logs/"))

func makeTail(cutPrefix string) http.Handler {
	tails := []*webtail.Tail{
		webtail.NewTail(filename),
	}

	term := webterm.New(
		&webtail.WebTail{Tails: tails},
        webterm.WithCutPrefix(cutPrefix),
        webterm.WithTheme(webterm.ThemeSolarizedDark),
        webterm.WithFontSize(11),
	)
	return term
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ControlBar

type ControlBar struct {
	Hide       bool   `json:"hide"`
	FontSize   int    `json:"fontSize,omitempty"`
	FontFamily string `json:"fontFamily,omitempty"`
}

type ExtMessage

type ExtMessage struct {
	Filter string   `json:"filter"`
	Files  []string `json:"files"`
}

type FileEntry

type FileEntry struct {
	Label string `json:"label"`
	ID    string `json:"id"`
}

type ITail

type ITail interface {
	Start() error
	Stop() error
	Lines() <-chan string
}

func NewMultiTail

func NewMultiTail(tails ...ITail) ITail

type MultiTail

type MultiTail struct {
	// contains filtered or unexported fields
}

MultiTail allows tailing multiple files and merging their output

func (*MultiTail) Lines

func (mt *MultiTail) Lines() <-chan string

func (*MultiTail) Start

func (mt *MultiTail) Start() error

func (*MultiTail) Stop

func (mt *MultiTail) Stop() error

type Option

type Option func(*Tail)

Option is a functional option for Tail

func WithBufferSize

func WithBufferSize(size int) Option

func WithLabel

func WithLabel(label string) Option

func WithLast

func WithLast(n int) Option

func WithPattern

func WithPattern(patterns ...string) Option

func WithPlugins

func WithPlugins(p ...Plugin) Option

func WithPollInterval

func WithPollInterval(d time.Duration) Option

WithPollInterval sets the polling interval for checking file changes

func WithSyntaxHighlighting

func WithSyntaxHighlighting(syntax ...string) Option

type Pattern

type Pattern []*regexp.Regexp

func (Pattern) Match

func (p Pattern) Match(s string) bool

type Plugin

type Plugin interface {
	// Apply processes a line and returns the modified line
	// and a boolean indicating processing ahead
	// if further plugins should continue processing
	// or drop the line.
	Apply(line string) (string, bool)
}

func NewWithSyntaxHighlighting

func NewWithSyntaxHighlighting(syntax ...string) Plugin

type Tail

type Tail struct {
	// contains filtered or unexported fields
}

Tail provides functionality to tail a file it works similar to 'tail -F' command in unix, which follows the file even if it is rotated

func NewTail

func NewTail(filename string, opts ...Option) *Tail

NewTail creates Tail instance

func (*Tail) Lines

func (tail *Tail) Lines() <-chan string

Lines returns output channel caller can read lines from this channel

func (*Tail) SetSilent

func (tail *Tail) SetSilent(silent bool)

func (*Tail) Start

func (tail *Tail) Start() error

Start begins tailing the file

func (*Tail) Stop

func (tail *Tail) Stop() error

Stop stops tailing the file

type TailConfig

type TailConfig struct {
	Filename   string
	Label      string
	Highlights []string
}

type WebTail

type WebTail struct {
	Tails []TailConfig
}

func (*WebTail) Session

func (wt *WebTail) Session() (webterm.Session, error)

func (*WebTail) Template

func (wt *WebTail) Template() (*template.Template, any)

type WebTailSession

type WebTailSession struct {
	// contains filtered or unexported fields
}

func (*WebTailSession) Close

func (wts *WebTailSession) Close() error

func (*WebTailSession) Control

func (wts *WebTailSession) Control(data []byte) error

func (*WebTailSession) Open

func (wts *WebTailSession) Open() error

func (*WebTailSession) Read

func (wts *WebTailSession) Read(p []byte) (n int, err error)

func (*WebTailSession) SetFilter

func (wts *WebTailSession) SetFilter(filter string)

func (*WebTailSession) SetWinSize

func (wts *WebTailSession) SetWinSize(cols, rows int) error

func (*WebTailSession) Write

func (wts *WebTailSession) Write(p []byte) (n int, err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL