(ctx context.Context, event *ch.QueryEvent)
| 53 | return ctx, nil |
| 54 | } |
| 55 | func (h *QueryHook) AfterQuery(ctx context.Context, event *ch.QueryEvent) { |
| 56 | if !h.enabled { |
| 57 | return |
| 58 | } |
| 59 | if !h.verbose { |
| 60 | switch event.Err { |
| 61 | case nil, sql.ErrNoRows: |
| 62 | return |
| 63 | } |
| 64 | } |
| 65 | now := time.Now() |
| 66 | dur := now.Sub(event.StartTime) |
| 67 | args := []any{"[ch]", now.Format(" 15:04:05.000 "), formatOperation(event), formatFileLine(), fmt.Sprintf(" %10s ", dur.Round(time.Microsecond)), event.Query} |
| 68 | if event.Err != nil { |
| 69 | typ := reflect.TypeOf(event.Err).String() |
| 70 | args = append(args, "\t", color.New(color.BgRed).Sprintf(" %s ", typ+": "+event.Err.Error())) |
| 71 | } |
| 72 | fmt.Fprintln(h.writer, args...) |
| 73 | } |
| 74 | func formatOperation(event *ch.QueryEvent) string { |
| 75 | operation := event.Operation() |
| 76 | return operationColor(operation).Sprintf(" %-16s ", operation) |
nothing calls this directly
no test coverage detected