Exemplo n.º 1
0
func doRequestParam(c *cli.Context) {
	param := c.String("param")
	// Show help if param flag is empty
	if param == "" {
		cli.ShowCommandHelp(c, c.Command.Name)
		return
	}
	reducer := elblog.NewRequestParamCount(param)
	reader := NewReader(c, reducer)
	entry, err := reader.Read()
	assert(err)
	o := &output.Output{}
	o.SetNames("request parameter value", "count")
	for k, v := range entry.Fields() {
		o.Add(k, v)
	}
	err = Output(c, o)
	assert(err)
}
Exemplo n.º 2
0
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)
	}
}