summaryrefslogtreecommitdiff
path: root/internal/mapr/logformat/parser.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2021-10-09 21:10:29 +0300
committerPaul Buetow <paul@buetow.org>2021-10-10 13:36:41 +0300
commit97747ea0f3178f7f5890512d483fdccaa82846b0 (patch)
tree9ff1335ca26afc90e55fd6de416457e252d75a35 /internal/mapr/logformat/parser.go
parent7a7169791a64190e1002e38bc9c04ad0d5c1ce1f (diff)
vetting and linting and some code restyling
Diffstat (limited to 'internal/mapr/logformat/parser.go')
-rw-r--r--internal/mapr/logformat/parser.go12
1 files changed, 2 insertions, 10 deletions
diff --git a/internal/mapr/logformat/parser.go b/internal/mapr/logformat/parser.go
index a352580..129081d 100644
--- a/internal/mapr/logformat/parser.go
+++ b/internal/mapr/logformat/parser.go
@@ -11,7 +11,8 @@ import (
"github.com/mimecast/dtail/internal/mapr"
)
-var IgnoreFieldsErr error = errors.New("Ignore this field set")
+// ErrIgnoreFields indicates that the fields should be ignored.
+var ErrIgnoreFields error = errors.New("Ignore this field set")
// Parser is used to parse the mapreduce information from the server log files.
type Parser struct {
@@ -26,11 +27,9 @@ type Parser struct {
// NewParser returns a new log parser.
func NewParser(logFormatName string, query *mapr.Query) (*Parser, error) {
hostname, err := os.Hostname()
-
if err != nil {
return nil, err
}
-
now := time.Now()
zone, offset := now.Zone()
@@ -44,7 +43,6 @@ func NewParser(logFormatName string, query *mapr.Query) (*Parser, error) {
if err != nil {
return nil, err
}
-
return &p, nil
}
@@ -53,7 +51,6 @@ func NewParser(logFormatName string, query *mapr.Query) (*Parser, error) {
// Parser. Whereas MODULENAME must be a upeprcase string.
func (p *Parser) reflectLogFormat(logFormatName string) error {
methodName := fmt.Sprintf("MakeFields%s", strings.ToUpper(logFormatName))
-
rt := reflect.TypeOf(p)
method, ok := rt.MethodByName(methodName)
if !ok {
@@ -62,7 +59,6 @@ func (p *Parser) reflectLogFormat(logFormatName string) error {
p.makeFieldsFunc = method.Func
p.makeFieldsReceiver = reflect.ValueOf(p)
-
return nil
}
@@ -70,15 +66,11 @@ func (p *Parser) reflectLogFormat(logFormatName string) error {
func (p *Parser) MakeFields(maprLine string) (fields map[string]string, err error) {
inputValues := []reflect.Value{p.makeFieldsReceiver, reflect.ValueOf(maprLine)}
returnValues := p.makeFieldsFunc.Call(inputValues)
-
errInterface := returnValues[1].Interface()
-
if errInterface == nil {
fields, err = returnValues[0].Interface().(map[string]string), nil
return
}
-
fields, err = returnValues[0].Interface().(map[string]string), errInterface.(error)
-
return
}