mirror of
https://github.com/Luzifer/bind-log-metrics.git
synced 2024-11-09 16:30:00 +00:00
Allow specifying input file
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
e4322c2f02
commit
0c248599e0
1 changed files with 13 additions and 1 deletions
14
main.go
14
main.go
|
@ -3,6 +3,7 @@ package main
|
|||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"regexp"
|
||||
|
||||
|
@ -62,7 +63,18 @@ func main() {
|
|||
log.WithError(err).Fatal("Unable to create metrics client")
|
||||
}
|
||||
|
||||
scanner := bufio.NewScanner(os.Stdin)
|
||||
var input io.Reader = os.Stdin
|
||||
if len(rconfig.Args()) > 1 {
|
||||
f, err := os.Open(rconfig.Args()[1])
|
||||
if err != nil {
|
||||
log.WithError(err).Fatal("Unable to open input file")
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
input = f
|
||||
}
|
||||
|
||||
scanner := bufio.NewScanner(input)
|
||||
for scanner.Scan() {
|
||||
var line = scanner.Text()
|
||||
|
||||
|
|
Loading…
Reference in a new issue