logger

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 4, 2026 License: AGPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TelegramBotTokenFn func() string
	TelegramChatIDFn   func() string
)
View Source
var OnChatMigrated func(oldID, newID string) error
View Source
var TelegramBaseOverrideFn func() string
View Source
var TelegramBaseURL = ""
View Source
var TelegramDurableFn func(chatID, text, parseMode string) error
View Source
var Version = "dev"

Functions

func AppRootDir

func AppRootDir() (string, error)

func ApplyChatMigration

func ApplyChatMigration(oldID, newID string)

func Configure

func Configure(logFilePath, logLevelStr string) error

func CurrentTelegramBaseURL

func CurrentTelegramBaseURL() string

func CurrentVersion

func CurrentVersion() string

func Debug

func Debug(format string, v ...interface{})

func EnqueueTelegramAlert

func EnqueueTelegramAlert(message string)

func Error

func Error(format string, v ...interface{})

func EscapeMarkdownV2

func EscapeMarkdownV2(text string) string

func Fatal

func Fatal(format string, v ...interface{})

func GetTelegramBotToken

func GetTelegramBotToken() string

func GetTelegramChatID

func GetTelegramChatID() string

func GetTraceID

func GetTraceID(ctx context.Context) string

func Info

func Info(format string, v ...interface{})

func InitSentry

func InitSentry(service string, overrides ...string)

func IsClientGone

func IsClientGone(err error) bool

func LocationFromRequest

func LocationFromRequest(r *http.Request) string

func LocationMiddleware

func LocationMiddleware(clientIP func(*http.Request) string) func(http.Handler) http.Handler

func LogWithContext

func LogWithContext(ctx context.Context, logLevel LogLevel, component, format string, v ...interface{})

func MigratedChatID

func MigratedChatID(body []byte) string

func MissingKey

func MissingKey(key string)

func NewContextWithTraceID

func NewContextWithTraceID(ctx context.Context) (context.Context, string)

func NewContextWithTraceIDValue

func NewContextWithTraceIDValue(ctx context.Context, traceID string) context.Context

func NewError

func NewError(format string, v ...interface{}) error

func Persistent

func Persistent(key string, threshold int, window time.Duration, format string, v ...interface{})

func PostTelegram

func PostTelegram(chatID, message, parseMode string) (ok bool, retryAfter time.Duration, detail string)

func Redact

func Redact(s string) string

func RememberLocation

func RememberLocation(ip, country, region, city string)

func RememberRequestLocation

func RememberRequestLocation(r *http.Request, ip string)

func RenderError

func RenderError(tmpl string, err error, r *http.Request, detail string)

func ResetPersistent

func ResetPersistent(key string)

func Retry

func Retry(p RetryPolicy, what string, op func() error) error

func SendTelegramMessage

func SendTelegramMessage(message string) bool

func SendTelegramMessageSync

func SendTelegramMessageSync(message string)

func SendToUserSync

func SendToUserSync(chatID string, message string)

func SentryBreadcrumb

func SentryBreadcrumb(level LogLevel, formattedLog string)

func SentryCapture

func SentryCapture(level LogLevel, formattedLog string)

func SentryFlush

func SentryFlush()

func SentryLog

func SentryLog(level LogLevel, formattedLog string)

func SentryRecover

func SentryRecover(v interface{})

func ServiceName

func ServiceName() string

func SetOnChatMigrated

func SetOnChatMigrated(fn func(oldID, newID string) error)

func SetService

func SetService(name string)

func SetTelegramBaseOverride

func SetTelegramBaseOverride(fn func() string)

func SetTelegramBaseURL

func SetTelegramBaseURL(base string)

func SetTelegramBotToken

func SetTelegramBotToken(fn func() string)

func SetTelegramChatID

func SetTelegramChatID(fn func() string)

func SetTimeZone

func SetTimeZone(name string)

func Setup

func Setup(o Options)

func StructuredLog

func StructuredLog(ctx context.Context, level string, component string, message string, fields map[string]interface{}) string

func TelegramBase

func TelegramBase() string

func Warn

func Warn(format string, v ...interface{})

Types

type AppLogger

type AppLogger struct {
	// contains filtered or unexported fields
}

func (*AppLogger) Debug

func (l *AppLogger) Debug(format string, v ...interface{})

func (*AppLogger) Error

func (l *AppLogger) Error(format string, v ...interface{})

func (*AppLogger) Fatal

func (l *AppLogger) Fatal(format string, v ...interface{})

func (*AppLogger) Info

func (l *AppLogger) Info(format string, v ...interface{})

func (*AppLogger) Warn

func (l *AppLogger) Warn(format string, v ...interface{})

type Entry

type Entry struct {
	At    time.Time
	Level string
	Msg   string
}

func Recent

func Recent() []Entry

type LogLevel

type LogLevel int
const (
	LevelDebug LogLevel = iota
	LevelInfo
	LevelWarn
	LevelError
	LevelFatal
)

func (LogLevel) String

func (l LogLevel) String() string

type Options

type Options struct {
	AppName               string
	DefaultServiceName    string
	DefaultTimeZone       string
	BuildVersionUpLevels  int
	SentryServiceSetsName bool
	ConfigValue           func(key string) string
	TenantTag             func() string
	TelegramBotToken      func() string
	TelegramChatID        func() string
	TelegramBaseOverride  func() string
}

type RetryPolicy

type RetryPolicy struct {
	Key       string
	Attempts  int
	Backoff   []time.Duration
	Threshold int
	Window    time.Duration
	Permanent func(error) bool
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL