Documentation ¶
Index ¶
- Constants
- func New(options ...Option) *logger
- type LogType
- type Option
- func SetLogLevel(key LogType, level slog.Level) Option
- func WithErrorField(field string) Option
- func WithIgnoreTrace() Option
- func WithLogger(log *slog.Logger) Option
- func WithRecordNotFoundError() Option
- func WithSlowThreshold(threshold time.Duration) Option
- func WithSourceField(field string) Option
- func WithTraceAll() Option
Constants ¶
View Source
const ( ErrorLogType LogType = "sql_error" SlowQueryLogType LogType = "slow_query" DefaultLogType LogType = "default" SourceField = "file" ErrorField = "error" QueryField = "query" DurationField = "duration" SlowQueryField = "slow_query" RowsField = "rows" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Option ¶
type Option func(l *logger)
func SetLogLevel ¶
SetLogLevel sets a new slog.Level for a LogType.
func WithErrorField ¶
WithErrorField defines the field to set the error
func WithIgnoreTrace ¶
func WithIgnoreTrace() Option
WithIgnoreTrace disables the tracing of SQL queries by the slogger
func WithLogger ¶
WithLogger defines a custom logger to use
func WithRecordNotFoundError ¶
func WithRecordNotFoundError() Option
WithRecordNotFoundError allows the slogger to log gorm.ErrRecordNotFound errors
func WithSlowThreshold ¶
WithSlowThreshold defines the threshold above which a sql query is considered slow
func WithSourceField ¶
WithSourceField defines the field to set the file name and line number of the current file
func WithTraceAll ¶
func WithTraceAll() Option
WithTraceAll enables mode which logs all SQL messages.
Click to show internal directories.
Click to hide internal directories.