Documentation ¶
Index ¶
- func ConsoleBuildLogFunc(ctx context.Context, ts time.Duration, sql string, args []interface{}, ...)
- func ConsoleExecLogFunc(ctx context.Context, ts time.Duration, sql string, args []interface{}, ...)
- func NewTraceId() string
- func Time2StringEncodeHook(typ reflect.Type, data interface{}) (interface{}, error)
- type BuildLogFunc
- type EncodeHookFunc
- type ExecLogFunc
- type SealOptions
- type SealOptionsFunc
- type TraceKey
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConsoleBuildLogFunc ¶
func ConsoleBuildLogFunc(ctx context.Context, ts time.Duration, sql string, args []interface{}, err error)
ConsoleBuildLogFunc 控制台日志输出
func ConsoleExecLogFunc ¶
func ConsoleExecLogFunc(ctx context.Context, ts time.Duration, sql string, args []interface{}, err error)
ConsoleExecLogFunc print the message to console
func Time2StringEncodeHook ¶
Time2StringEncodeHook converts time.Time to string which the layout
Types ¶
type BuildLogFunc ¶
type BuildLogFunc func(ctx context.Context, ts time.Duration, sql string, args []interface{}, err error)
BuildLogFunc is called each time when we build a sql statement and args. The "ts" parameter gives the time that the build takes, while sql,args and err refer to the result of the execution.
type EncodeHookFunc ¶
EncodeHookFunc this defined a func which will be called on each value when we use a INSERT clause
func GroupEncodeHook ¶
func GroupEncodeHook(fns ...EncodeHookFunc) EncodeHookFunc
GroupEncodeHook support multi EncodeHookFunc The composed funcs are called in order, with the result of the previous transformation.
type ExecLogFunc ¶
type ExecLogFunc func(ctx context.Context, ts time.Duration, sql string, args []interface{}, err error)
ExecLogFunc is called each time when a SQL statement is executed. The "ts" parameter gives the time that the SQL statement takes to execute, sql and args refer the exec params err refer to the result of the execution.
type SealOptions ¶
type SealOptions struct { EncodeHook EncodeHookFunc ExecLog ExecLogFunc BuildLog BuildLogFunc }
SealOptions the global options
func DefaultSealOptions ¶
func DefaultSealOptions() *SealOptions
DefaultSealOptions only contains the EncodeHook
type SealOptionsFunc ¶
type SealOptionsFunc func(opt *SealOptions)
SealOptionsFunc SealOptions
func WithBuildLogger ¶
func WithBuildLogger(blog BuildLogFunc) SealOptionsFunc
WithBuildLogger set the sql build log
func WithEncodeHook ¶
func WithEncodeHook(ehook EncodeHookFunc) SealOptionsFunc
WithEncodeHook set encode hook. we can set nil to encode hook func if we want drop the default encode hook
func WithExecLogger ¶
func WithExecLogger(elog ExecLogFunc) SealOptionsFunc
WithExecLogger set execlog func