Lightweight MySQL slow query log parser in Go
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.circleci
_test
cmd/stdin-parser
LICENSE
README.md
attributes.go
parser.go
parser_test.go

README.md

mysqllog GoDoc CircleCI

This package provides a simple MySQL slow query log parser.

Example: Parse a log from stdin and print events as JSON

package main

import (
	"bufio"
	"encoding/json"
	"fmt"
	"os"

	"github.com/Preetam/mysqllog"
)

func main() {
	p := &mysqllog.Parser{}
	reader := bufio.NewReader(os.Stdin)
	for line, err := reader.ReadString('\n'); err == nil; line, err = reader.ReadString('\n') {
		event := p.ConsumeLine(line)
		if event != nil {
			b, _ := json.Marshal(event)
			fmt.Printf("%s\n", b)
		}
	}
}

License

MIT (see LICENSE)