Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BatchSender ¶
type BatchSender struct {
// contains filtered or unexported fields
}
func NewBatchSender ¶
func NewBatchSender(parent Sender, batchSize uint64, flushInterval time.Duration) *BatchSender
func (*BatchSender) Close ¶
func (s *BatchSender) Close() error
func (*BatchSender) Send ¶
func (s *BatchSender) Send(msg string) error
type Formatter ¶
func NewFormatter ¶
func NewFormatter(opts FormatterOptions) Formatter
type FormatterOptions ¶
type FormatterOptions struct { // Template is a Go template to format the log record. Template string // LevelFormatter is a custom function to format the log level. LevelFormatter func(slog.Record) string // TimeFormatter is a custom function to format the log time. TimeFormatter func(slog.Record) string // MessageFormatter is a custom function to format the log message. MessageFormatter func(slog.Record) string // AttrsFormatter is a custom function to format the log attributes. AttrsFormatter func(slog.Record) string // Instance is a custom formatter instance to use. Instance Formatter }
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
func DefaultHandler ¶
func NewHandler ¶
func NewHandler(opts HandlerOptions) *Handler
type HandlerOptions ¶
type HandlerOptions struct { // Level reports the minimum record level that will be logged. // The handler discards records with lower levels. // If Level is nil, the handler assumes LevelInfo. // The handler calls Level.Level for each record processed; // to adjust the minimum level dynamically, use a LevelVar. Level slog.Leveler // Formatter is a config to format the log record before sending. Formatter FormatterOptions // Sender is a config to send the formatted log record to a telegram chat. Sender SenderOptions }
type SenderOptions ¶
type SenderOptions struct { // Token is the Telegram bot token to send messages. It is required, please generate it from @BotFather. Token string // ChatID is the chat ID to send messages to (private, group or channel). ChatID int64 // HTTPClient is the client used to send messages to the Telegram API. HTTPClient *http.Client // BaseURL is the Telegram API basic url to send messages. BaseURL string // BatchSize is the maximum number of messages to send in a single batch. BatchSize uint64 // FlushInterval is the maximum duration to wait before sending a batch. FlushInterval time.Duration // Verbose specifies whether to print the Telegram API requests and responses. Verbose bool // Instance is a custom sender instance to use. Instance Sender }
type TelebotSender ¶
type TelebotSender struct {
// contains filtered or unexported fields
}
func NewTelebotSender ¶
func NewTelebotSender(client client, chatID int64) *TelebotSender
func (*TelebotSender) Close ¶
func (s *TelebotSender) Close() error
func (*TelebotSender) Send ¶
func (s *TelebotSender) Send(msg string) error
Click to show internal directories.
Click to hide internal directories.