Initial commit

This commit is contained in:
Donny
2019-04-22 20:46:32 +08:00
commit 49ab8aadd1
25441 changed files with 4055000 additions and 0 deletions

36
vendor/github.com/vjeantet/grok/example/BUILD generated vendored Normal file
View File

@@ -0,0 +1,36 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_binary",
"go_library",
)
go_binary(
name = "example",
embed = [":go_default_library"],
tags = ["automanaged"],
)
go_library(
name = "go_default_library",
srcs = ["main.go"],
importpath = "github.com/vjeantet/grok/example",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = ["//vendor/github.com/vjeantet/grok:go_default_library"],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

34
vendor/github.com/vjeantet/grok/example/main.go generated vendored Normal file
View File

@@ -0,0 +1,34 @@
package main
import (
"fmt"
"github.com/vjeantet/grok"
)
func main() {
fmt.Println("# Default Capture :")
g, _ := grok.New()
values, _ := g.Parse("%{COMMONAPACHELOG}", `127.0.0.1 - - [23/Apr/2014:22:58:32 +0200] "GET /index.php HTTP/1.1" 404 207`)
for k, v := range values {
fmt.Printf("%+15s: %s\n", k, v)
}
fmt.Println("\n# Named Capture :")
g, _ = grok.NewWithConfig(&grok.Config{NamedCapturesOnly: true})
values, _ = g.Parse("%{COMMONAPACHELOG}", `127.0.0.1 - - [23/Apr/2014:22:58:32 +0200] "GET /index.php HTTP/1.1" 404 207`)
for k, v := range values {
fmt.Printf("%+15s: %s\n", k, v)
}
fmt.Println("\n# Add custom patterns :")
// We add 3 patterns to our Grok instance, to structure an IRC message
g, _ = grok.NewWithConfig(&grok.Config{NamedCapturesOnly: true})
g.AddPattern("IRCUSER", `\A@(\w+)`)
g.AddPattern("IRCBODY", `.*`)
g.AddPattern("IRCMSG", `%{IRCUSER:user} .* : %{IRCBODY:message}`)
values, _ = g.Parse("%{IRCMSG}", `@vjeantet said : Hello !`)
for k, v := range values {
fmt.Printf("%+15s: %s\n", k, v)
}
}