Help us shape the future of Go! Take the 2026 Go Developer Survey

applog

package
v1.37.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const MaxReadBytes = 512 * 1024

MaxReadBytes is the maximum number of bytes to read from the end of a file.

Variables

This section is empty.

Functions

func FormatForFile

func FormatForFile(sources []config.FrameworkLogSource, filename string) string

FormatForFile returns the log format string for the given filename based on the framework's log sources. Falls back to "raw".

func MarkPastTail added in v1.37.0

func MarkPastTail(page []LogEntry, offset, tailLen int)

MarkPastTail flags the entries of a page taken at offset that fall outside the newest tailLen entries, the ones a capped tail read returns.

func ResolveLogFilePath

func ResolveLogFilePath(projectDir string, sources []config.FrameworkLogSource, filename string) string

ResolveLogFilePath finds the full path for a log file by name within the configured sources. Returns empty string if not found or path traversal detected.

Types

type LogEntry

type LogEntry struct {
	Level   string `json:"level"`
	Date    string `json:"date"`
	Channel string `json:"channel"`
	Message string `json:"message"`
	Detail  string `json:"detail,omitempty"`
	// PastTail marks an entry older than the tail ParseFile reads, which a
	// capped reader such as the MCP logs tool cannot reach.
	PastTail bool `json:"past_tail,omitempty"`
}

LogEntry represents a single parsed log entry.

func Page added in v1.36.0

func Page(entries []LogEntry, offset, limit int) ([]LogEntry, bool)

Page returns limit entries starting at offset, and whether any follow, so a file too large to send in one response can be read a page at a time.

func ParseFile

func ParseFile(path, format string, maxEntries int) ([]LogEntry, error)

ParseFile reads the tail of a log file and parses up to maxEntries entries. When maxEntries is 0, the entire file is read and all entries are returned. Returns entries in reverse-chronological order (newest first).

type LogFile

type LogFile struct {
	Name    string `json:"name"`
	Size    int64  `json:"size"`
	ModTime string `json:"mod_time"`
}

LogFile represents an available log file on disk.

func DiscoverLogFiles

func DiscoverLogFiles(projectDir string, sources []config.FrameworkLogSource) ([]LogFile, error)

DiscoverLogFiles expands the configured log source globs for a project and returns the matching files sorted by modification time (newest first). Resolved paths are validated to stay within projectDir.

Jump to

Keyboard shortcuts

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