Documentation
¶
Index ¶
Constants ¶
View Source
const ( // LevelTrace trace level LEVEL_TRACE = "trace" // LevelDebug debug level LEVEL_DEBUG = "debug" // LevelError error level LEVEL_ERROR = "error" // LevelFatal fatal level LEVEL_FATAL = "fatal" // LevelInfo info level LEVEL_INFO = "info" // LevelPanic panic level LEVEL_PANIC = "panic" // LevelWarning warning level LEVEL_WARNING = "warning" )
Log levels
View Source
const COLUMN_CONTEXT = "context"
View Source
const COLUMN_ID = "id"
View Source
const COLUMN_LEVEL = "level"
View Source
const COLUMN_MESSAGE = "message"
View Source
const COLUMN_TIME = "time"
Variables ¶
View Source
var ( ErrLogTableNameRequired = errors.New("log store: logTableName is required") ErrDBRequired = errors.New("log store: DB is required") )
Errors
Functions ¶
func NewStore ¶
func NewStore(opts NewStoreOptions) (*storeImplementation, error)
NewStore creates a new session store
Types ¶
type LogInterface ¶ added in v1.10.0
type LogInterface interface {
GetID() string
SetID(id string) LogInterface
GetLevel() string
SetLevel(level string) LogInterface
GetMessage() string
SetMessage(message string) LogInterface
GetContext() string
SetContext(context string) LogInterface
GetTime() time.Time
SetTime(t time.Time) LogInterface
GetTimeCarbon() *carbon.Carbon
SetTimeCarbon(t *carbon.Carbon) LogInterface
}
LogInterface defines the public API for a log entry
func NewLog ¶ added in v1.10.0
func NewLog() LogInterface
NewLog creates a new log with the current UTC time
func NewLogWithData ¶ added in v1.10.0
func NewLogWithData(id, level, message, context string, t time.Time) LogInterface
NewLogWithData creates a new log from existing values
type LogQueryInterface ¶ added in v1.10.0
type LogQueryInterface interface {
// Validation method
Validate() error
// Dataset conversion methods
ToSelectDataset(store StoreInterface) (selectDataset *goqu.SelectDataset, columns []any, err error)
IsIDSet() bool
GetID() string
SetID(id string) LogQueryInterface
IsIDInSet() bool
GetIDIn() []string
SetIDIn(ids []string) LogQueryInterface
IsLevelSet() bool
GetLevel() string
SetLevel(level string) LogQueryInterface
IsLevelInSet() bool
GetLevelIn() []string
SetLevelIn(levels []string) LogQueryInterface
IsMessageContainsSet() bool
GetMessageContains() string
SetMessageContains(term string) LogQueryInterface
IsMessageNotContainsSet() bool
GetMessageNotContains() string
SetMessageNotContains(term string) LogQueryInterface
IsContextContainsSet() bool
GetContextContains() string
SetContextContains(term string) LogQueryInterface
IsContextNotContainsSet() bool
GetContextNotContains() string
SetContextNotContains(term string) LogQueryInterface
IsTimeGteSet() bool
GetTimeGte() string
SetTimeGte(time string) LogQueryInterface
IsTimeLteSet() bool
GetTimeLte() string
SetTimeLte(time string) LogQueryInterface
IsLimitSet() bool
GetLimit() int
SetLimit(limit int) LogQueryInterface
IsOffsetSet() bool
GetOffset() int
SetOffset(offset int) LogQueryInterface
IsOrderBySet() bool
GetOrderBy() string
SetOrderBy(orderBy string) LogQueryInterface
IsOrderDirectionSet() bool
GetOrderDirection() string
SetOrderDirection(orderDirection string) LogQueryInterface
}
LogQueryInterface defines the interface for querying logs
type NewStoreOptions ¶
type NewStoreOptions struct {
LogTableName string
DB *sql.DB
DbDriverName string
AutomigrateEnabled bool
DebugEnabled bool
}
NewStoreOptions define the options for creating a new session store
type SlogHandler ¶
type SlogHandler struct {
// contains filtered or unexported fields
}
func NewSlogHandler ¶
func NewSlogHandler(logStore StoreInterface) *SlogHandler
type StoreInterface ¶
type StoreInterface interface {
// AutoMigrate creates the necessary database tables
AutoMigrate() error
// EnableDebug enables or disables debug mode
EnableDebug(debug bool)
GetDriverName() string
GetLogTableName() string
// Log adds a log entry
Log(logEntry LogInterface) error
// Debug adds a debug log
Debug(message string) error
// DebugWithContext adds a debug log with context data
DebugWithContext(message string, context interface{}) error
// Error adds an error log
Error(message string) error
// ErrorWithContext adds an error log with context data
ErrorWithContext(message string, context interface{}) error
// Fatal adds a fatal log
Fatal(message string) error
// FatalWithContext adds a fatal log with context data
FatalWithContext(message string, context interface{}) error
// Info adds an info log
Info(message string) error
// InfoWithContext adds an info log with context data
InfoWithContext(message string, context interface{}) error
// Panic adds a panic log and calls panic(message) after logging
Panic(message string)
// PanicWithContext adds a panic log with context data and calls panic(message) after logging
PanicWithContext(message string, context interface{})
// Trace adds a trace log
Trace(message string) error
// TraceWithContext adds a trace log with context data
TraceWithContext(message string, context interface{}) error
// Warn adds a warn log
Warn(message string) error
// WarnWithContext adds a warn log with context data
WarnWithContext(message string, context interface{}) error
LogCount(ctx context.Context, query LogQueryInterface) (int, error)
LogCreate(ctx context.Context, logEntry LogInterface) error
LogList(ctx context.Context, query LogQueryInterface) ([]LogInterface, error)
LogDelete(ctx context.Context, logEntry LogInterface) error
LogDeleteByID(ctx context.Context, id string) error
LogFindByID(ctx context.Context, id string) (LogInterface, error)
}
StoreInterface defines the interface for a log store
Click to show internal directories.
Click to hide internal directories.