Skip to content

Preetam/mysqllog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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)

About

Lightweight MySQL slow query log parser in Go

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages