-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpg.go
37 lines (30 loc) · 974 Bytes
/
pg.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package pgstore
import (
"context"
"fmt"
)
const (
LogLevelDebug = LogLevel("DEBUG") // debug level
LogLevelInfo = LogLevel("INFO") // info level
LogLevelWarn = LogLevel("WARN") // warn level
LogLevelError = LogLevel("ERROR") // error level
)
var (
// ErrNoTable is returned when no table was provided.
ErrNoTable = fmt.Errorf("no table provided")
// ErrNoConnPool is returned when no database was provided.
ErrNoConnPool = fmt.Errorf("no connection pool provided")
// ErrNoLogger is returned when no logger was provided.
ErrNoLogger = fmt.Errorf("no logger provided")
)
// LogLevel is a log level.
type LogLevel string
// Logger wraps a logger to log messages.
type Logger interface {
// Log logs a message.
Log(ctx context.Context, level LogLevel, msg string, args ...any)
}
// NoopLogger is a logger that does nothing.
type NoopLogger struct{}
// Log logs a message.
func (l *NoopLogger) Log(_ context.Context, _ LogLevel, _ string, _ ...any) {}