diff --git a/README.md b/README.md index 8e5e12e..c41d611 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ Usage ```go func main() { // Instantiate Parser - p := logparser.NewParser() + p := parser.NewParser() // Multiple patterns can be set at the same time and matched in order // Each pattern must have at least one named capture group @@ -73,9 +73,9 @@ Customize Processing of each matched line and metadata output can be overridden when Parser instantiation. ```go -p = logparser.NewParser( - logparser.WithLineHandler(yourCustomLineHandler), - logparser.WithMetadataHandler(yourCustomMetadataHandler), +p = parser.NewParser( + parser.WithLineHandler(yourCustomLineHandler), + parser.WithMetadataHandler(yourCustomMetadataHandler), ) ``` @@ -91,24 +91,24 @@ func prettyJSON(s string) (string, error) { } func prettyJSONLineHandler(matches []string, fields []string, index int) (string, error) { - s, err := logparser.DefaultLineHandler(matches, fields, index) + s, err := parser.DefaultLineHandler(matches, fields, index) if err != nil { return "", err } return prettyJSON(s) } -func prettyJSONMetadataHandler(m *logparser.Metadata) (string, error) { - s, err := logparser.DefaultMetadataHandler(m) +func prettyJSONMetadataHandler(m *parser.Metadata) (string, error) { + s, err := parser.DefaultMetadataHandler(m) if err != nil { return "", err } return prettyJSON(s) } -p = logparser.NewParser( - logparser.WithLineHandler(prettyJSONLineHandler), - logparser.WithMetadataHandler(prettyJSONMetadataHandler), +p = parser.NewParser( + parser.WithLineHandler(prettyJSONLineHandler), + parser.WithMetadataHandler(prettyJSONMetadataHandler), ) ``` diff --git a/_example/main.go b/_example/main.go index 154c5f5..489bd4c 100644 --- a/_example/main.go +++ b/_example/main.go @@ -22,7 +22,7 @@ xxx yyy zzz func main() { // default - p := logparser.NewParser() + p := parser.NewParser() if err := p.AddPatterns(patterns); err != nil { log.Fatal(err) } @@ -41,9 +41,9 @@ func main() { */ // customize - p = logparser.NewParser( - logparser.WithLineHandler(prettyJSONLineHandler), - logparser.WithMetadataHandler(prettyJSONMetadataHandler), + p = parser.NewParser( + parser.WithLineHandler(prettyJSONLineHandler), + parser.WithMetadataHandler(prettyJSONMetadataHandler), ) if err := p.AddPatterns(patterns); err != nil { log.Fatal(err) @@ -94,15 +94,15 @@ func prettyJSON(s string) (string, error) { } func prettyJSONLineHandler(matches []string, fields []string, index int) (string, error) { - s, err := logparser.DefaultLineHandler(matches, fields, index) + s, err := parser.DefaultLineHandler(matches, fields, index) if err != nil { return "", err } return prettyJSON(s) } -func prettyJSONMetadataHandler(m *logparser.Metadata) (string, error) { - s, err := logparser.DefaultMetadataHandler(m) +func prettyJSONMetadataHandler(m *parser.Metadata) (string, error) { + s, err := parser.DefaultMetadataHandler(m) if err != nil { return "", err } diff --git a/logparser.go b/parser.go similarity index 98% rename from logparser.go rename to parser.go index cf9573b..5ea9134 100644 --- a/logparser.go +++ b/parser.go @@ -1,5 +1,5 @@ -// Package logparser provides utilities for parsing access logs and converting them to structured formats. -package logparser +// Package parser provides utilities for parsing access logs and converting them to structured formats. +package parser import ( "archive/zip" @@ -15,7 +15,7 @@ import ( ) // Version of access-log-parser. -const Version = "0.0.7" +const Version = "0.0.6" // Parser is a struct that defines how to parse the access log. // Patterns represents a list of regular expression patterns used for matching log lines, diff --git a/logparser_test.go b/parser_test.go similarity index 99% rename from logparser_test.go rename to parser_test.go index 1f451e7..3c2d22c 100644 --- a/logparser_test.go +++ b/parser_test.go @@ -1,4 +1,4 @@ -package logparser +package parser import ( "fmt"