func NewReader(c *cli.Context, reducer gonx.Reducer) *elblog.Reader { f, err := file(c.Args()) assert(err) if reducer == nil { reducer = new(gonx.ReadAll) } return elblog.NewReader(f, reducer) }
func TestCountRequestParam(t *testing.T) { f, err := os.Open("testdata/count_request_param.log") if err != nil { t.Fatal(err) } param := "test_param" reducer := elblog.NewRequestParamCount(param) reader := elblog.NewReader(f, reducer) entry, err := reader.Read() if err != nil && err != io.EOF { t.Fatal(err) } want := gonx.NewEntry(gonx.Fields{ "foo": "2", "bar": "1", "baz": "1", "quuix": "1", }) if !reflect.DeepEqual(entry, want) { t.Fatalf("want %v got %v", want, entry) } }