Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/preetam/mysqllog
Lightweight MySQL slow query log parser in Go
https://github.com/preetam/mysqllog
golang log mysql parser
Last synced: about 1 month ago
JSON representation
Lightweight MySQL slow query log parser in Go
- Host: GitHub
- URL: https://github.com/preetam/mysqllog
- Owner: Preetam
- License: mit
- Created: 2017-12-24T03:02:11.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2022-01-27T20:47:06.000Z (almost 3 years ago)
- Last Synced: 2024-09-28T15:41:39.231Z (about 2 months ago)
- Topics: golang, log, mysql, parser
- Language: Go
- Homepage:
- Size: 17.6 KB
- Stars: 33
- Watchers: 3
- Forks: 9
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# mysqllog [![GoDoc](https://godoc.org/github.com/Preetam/mysqllog?status.svg)](https://godoc.org/github.com/Preetam/mysqllog) [![CircleCI](https://circleci.com/gh/Preetam/mysqllog.svg?style=svg)](https://circleci.com/gh/Preetam/mysqllog)
This package provides a simple MySQL slow query log parser.
## Example: Parse a log from stdin and print events as JSON
```go
package mainimport (
"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)