| 38 | } |
| 39 | |
| 40 | func TestPrefix(t *testing.T) { |
| 41 | buf := new(bytes.Buffer) |
| 42 | SetOutput(buf) |
| 43 | SetPrefix("foo", "bar") |
| 44 | Printkv(context.Background(), "baz", 1) |
| 45 | SetOutput(os.Stdout) |
| 46 | |
| 47 | got := buf.String() |
| 48 | wantPrefix := "at=log_test.go:44 foo=bar " |
| 49 | if !strings.HasPrefix(got, wantPrefix) { |
| 50 | t.Errorf("output = %q want prefix %q", got, wantPrefix) |
| 51 | } |
| 52 | |
| 53 | SetPrefix() |
| 54 | if procPrefix != nil { |
| 55 | t.Errorf("procPrefix = %q want nil", procPrefix) |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | func TestAddPrefixkv0(t *testing.T) { |
| 60 | got := prefix(context.Background()) |