logger

package
v0.0.0-...-ae0b575 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FilterCriteria

type FilterCriteria struct {
	MinDuration time.Duration
	MaxDuration time.Duration
	Database    string
	User        string
	QueryType   string // SELECT, INSERT, UPDATE, DELETE
	MinReads    int64
	MaxReads    int64
}

type LogEntry

type LogEntry struct {
	Timestamp time.Time `json:"timestamp"`
	Duration  int64     `json:"duration_ms"`
	Database  string    `json:"database"`
	User      string    `json:"user"`
	Query     string    `json:"query"`
	Reads     int64     `json:"logical_reads"`
	Writes    int64     `json:"writes"`
	CPU       int64     `json:"cpu_ms"`
	SPID      int       `json:"spid"`
}

func FilterEntries

func FilterEntries(entries []LogEntry, criteria FilterCriteria) []LogEntry

FilterEntries filters log entries based on criteria

type LogFormat

type LogFormat int

Supported log formats for SQL Server

const (
	FormatUnknown LogFormat = iota
	FormatProfiler
	FormatExtendedEvents
	FormatQueryStore
	FormatErrorLog
	FormatPerformanceCounter
)

func (LogFormat) String

func (lf LogFormat) String() string

type LogFormatDetector

type LogFormatDetector struct{}

LogFormatDetector helps identify the format of log files

func NewLogFormatDetector

func NewLogFormatDetector() *LogFormatDetector

func (*LogFormatDetector) DetectFormat

func (d *LogFormatDetector) DetectFormat(sample string) LogFormat

type LogMetrics

type LogMetrics struct {
	TotalEntries       int            `json:"total_entries"`
	QueryTypes         map[string]int `json:"query_types"`
	AvgDuration        float64        `json:"avg_duration_ms"`
	MaxDuration        int64          `json:"max_duration_ms"`
	MinDuration        int64          `json:"min_duration_ms"`
	TotalReads         int64          `json:"total_reads"`
	TotalWrites        int64          `json:"total_writes"`
	DatabaseCounts     map[string]int `json:"database_counts"`
	HourlyDistribution map[int]int    `json:"hourly_distribution"`
}

LogMetrics provides statistics about parsed logs

func CalculateMetrics

func CalculateMetrics(entries []LogEntry) LogMetrics

type SQLServerLogParser

type SQLServerLogParser struct{}

func NewSQLServerLogParser

func NewSQLServerLogParser() *SQLServerLogParser

func (*SQLServerLogParser) ParseLog

func (p *SQLServerLogParser) ParseLog(reader io.Reader) ([]LogEntry, error)

func (*SQLServerLogParser) ParseLogFile

func (p *SQLServerLogParser) ParseLogFile(filename string) ([]LogEntry, error)

ParseLogFile parses a log file by path.

Jump to

Keyboard shortcuts

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