12345678910111213141516171819202122232425262728293031323334353637 |
- package dbutil
- import (
- "fmt"
- "io"
- )
- type Writer struct {
- io.Writer
- }
- func (w *Writer) Print(v ...interface{}) {
- if len(v) == 0 {
- return
- }
- if len(v) == 1 {
- fmt.Fprint(w.Writer, v[0])
- return
- }
- switch v[0] {
- case "sql":
- fmt.Fprintf(w.Writer, "[sql] [%s] [%s] %s %v (%d rows affected)", v[1:]...)
- case "log":
- fmt.Fprintf(w.Writer, "[log] [%s] %s", v[1:]...)
- case "error":
- fmt.Fprintf(w.Writer, "[err] [%s] %s", v[1:]...)
- default:
- fmt.Fprint(w.Writer, v...)
- }
- }
|