logtool

package
v0.0.28 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Categories = []string{"commons", "rest", "console"}
View Source
var Levels = []string{"debug", "info", "warn", "error", "fatal", "dpanic"}

Functions

func DownloadLogs

func DownloadLogs(ctx *gin.Context, path string) *errors.Error

DownloadLogs downloads logs based on categories and conditions

func ListLogFiles

func ListLogFiles(opts SearchOptions) (map[string]string, error)

func MonitorLogs

func MonitorLogs(ctx *gin.Context, opts SearchOptions) *errors.Error

MonitorLogs monitors logs based on categories and conditions in real-time

Types

type ContextLogLine

type ContextLogLine struct {
	FilePath   string     `json:"path"`
	LineNumber int64      `json:"line"`
	Content    string     `json:"content"`
	Record     *LogRecord `json:"record"`
}

func FetchContextLines

func FetchContextLines(filePath string, centerLine, contextRange int64) ([]ContextLogLine, *errors.Error)

FetchContextLines Read context lines around the center line

type LogRecord

type LogRecord struct {
	Level   string            `json:"level"`
	Time    string            `json:"time"`
	Msg     string            `json:"msg"`
	TraceID string            `json:"_trace_id_"`
	Error   string            `json:"error"`
	Data    map[string]string `json:"data"`
}

func (*LogRecord) ParsedTime

func (r *LogRecord) ParsedTime() (time.Time, error)

func (*LogRecord) ToJsonStr

func (r *LogRecord) ToJsonStr() string

func (*LogRecord) Validate

func (r *LogRecord) Validate() error

type MatchedRecord

type MatchedRecord struct {
	FilePath   string     `json:"path"`
	LineNumber int64      `json:"line"`
	Record     *LogRecord `json:"record"`
}

func SearchLogs

func SearchLogs(opts SearchOptions) ([]MatchedRecord, *errors.Error)

func (MatchedRecord) ToJsonStr

func (m MatchedRecord) ToJsonStr() string

type SearchOptions

type SearchOptions struct {
	Categories []string `json:"categories" form:"categories"`
	Level      string   `json:"level" form:"level"`
	TraceID    string   `json:"traceID" form:"traceID"`
	Keyword    string   `json:"keyword" form:"keyword"`
	StartTime  string   `json:"startTime" form:"startTime"`
	EndTime    string   `json:"endTime" form:"endTime"`

	RootDir  string `json:"root_dir" form:"rootDir"`
	Size     int    `json:"size" form:"size"`
	LastPath string `json:"lastPath" form:"lastPath"`
	LastLine int64  `json:"lastLine" form:"lastLine"`
}

Jump to

Keyboard shortcuts

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