Documentation ¶
Index ¶
- Constants
- func CaptureException(err error, tags Tags)
- func CaptureMessage(msg string, tags Tags)
- func GetLoggerPath() (*os.File, error)
- func GetLoggerPathFS(fs FileSystem) (fs.File, error)
- func InitSentry(disabled bool, commit string)
- func Reraise(err any, tags Tags)
- type Commit
- type CoreLogger
- func (cl *CoreLogger) CaptureError(msg string, err error, args ...any)
- func (cl *CoreLogger) CaptureFatal(msg string, err error, args ...any)
- func (cl *CoreLogger) CaptureFatalAndPanic(msg string, err error, args ...any)
- func (cl *CoreLogger) CaptureInfo(msg string, args ...any)
- func (cl *CoreLogger) CaptureWarn(msg string, args ...any)
- func (cl *CoreLogger) GetCaptureException() func(err error, tags Tags)
- func (cl *CoreLogger) GetCaptureMessage() func(msg string, tags Tags)
- func (cl *CoreLogger) GetLogger() *slog.Logger
- func (cl *CoreLogger) GetTags() Tags
- func (cl *CoreLogger) Reraise(args ...any)
- func (cl *CoreLogger) SetTags(tags Tags)
- type CoreLoggerOption
- type FileSystem
- type OsFs
- type Peeker
- type Printer
- type SentryClient
- type Tags
Constants ¶
const LevelFatal = slog.Level(12)
Variables ¶
This section is empty.
Functions ¶
func CaptureException ¶
func CaptureMessage ¶
func GetLoggerPath ¶
func GetLoggerPathFS ¶
func GetLoggerPathFS(fs FileSystem) (fs.File, error)
GetLoggerPathFS function with FileSystem parameter
func InitSentry ¶
Types ¶
type CoreLogger ¶
func NewCoreLogger ¶
func NewCoreLogger(logger *slog.Logger, opts ...CoreLoggerOption) *CoreLogger
func NewNoOpLogger ¶
func NewNoOpLogger() *CoreLogger
func (*CoreLogger) CaptureError ¶
func (cl *CoreLogger) CaptureError(msg string, err error, args ...any)
CaptureError logs an error and sends it to sentry.
func (*CoreLogger) CaptureFatal ¶
func (cl *CoreLogger) CaptureFatal(msg string, err error, args ...any)
CaptureFatal logs an error at the fatal level and sends it to sentry.
func (*CoreLogger) CaptureFatalAndPanic ¶
func (cl *CoreLogger) CaptureFatalAndPanic(msg string, err error, args ...any)
CaptureFatalAndPanic logs an error at the fatal level and sends it to sentry. It then panics.
func (*CoreLogger) CaptureInfo ¶
func (cl *CoreLogger) CaptureInfo(msg string, args ...any)
CaptureInfo logs an info message and sends it to sentry.
func (*CoreLogger) CaptureWarn ¶
func (cl *CoreLogger) CaptureWarn(msg string, args ...any)
CaptureWarn logs a warning and sends it to sentry.
func (*CoreLogger) GetCaptureException ¶
func (cl *CoreLogger) GetCaptureException() func(err error, tags Tags)
GetCaptureException returns the function used to capture exceptions.
func (*CoreLogger) GetCaptureMessage ¶
func (cl *CoreLogger) GetCaptureMessage() func(msg string, tags Tags)
GetCaptureMessage returns the function used to capture messages.
func (*CoreLogger) GetLogger ¶
func (cl *CoreLogger) GetLogger() *slog.Logger
GetLogger returns the underlying slog.Logger.
func (*CoreLogger) GetTags ¶
func (cl *CoreLogger) GetTags() Tags
GetTags returns the tags associated with the logger.
func (*CoreLogger) Reraise ¶
func (cl *CoreLogger) Reraise(args ...any)
Reraise is used to capture unexpected panics with sentry and reraise them.
func (*CoreLogger) SetTags ¶
func (cl *CoreLogger) SetTags(tags Tags)
type CoreLoggerOption ¶
type CoreLoggerOption func(cl *CoreLogger)
func WithCaptureException ¶
func WithCaptureException(f func(err error, tags Tags)) CoreLoggerOption
func WithCaptureMessage ¶
func WithCaptureMessage(f func(msg string, tags Tags)) CoreLoggerOption
func WithTags ¶
func WithTags(tags Tags) CoreLoggerOption
type FileSystem ¶
type FileSystem interface { MkdirAll(path string, perm os.FileMode) error OpenFile(name string, flag int, perm os.FileMode) (fs.File, error) }
FileSystem interface to abstract file system operations
type OsFs ¶
type OsFs struct{}
OsFs wraps standard os package functions to satisfy the FileSystem interface.
type Peeker ¶
Peeker stores HTTP responses for failed requests.
func (*Peeker) Read ¶
func (p *Peeker) Read() []*service.HttpResponse
Read returns the buffered responses and clears the buffer.
type Printer ¶
Printer stores console messages to display to the user.
func NewPrinter ¶
func NewPrinter() *Printer
func (*Printer) AtMostEvery ¶
AtMostEvery allows rate-limiting how often a message is printed.
Usage:
printer. AtMostEvery(time.Minute). Write(message)
Note, this doesn't affect regular `printer.Write(message)` calls. The duration is only checked when `AtMostEvery()` is used.
This should always be used with the same duration. If the duration changes, the message is blocked until its last duration completes.