Documentation
¶
Index ¶
- Variables
- func AddOutput(writer io.Writer)
- func Debug(err error)
- func Debugf(format string, v ...interface{})
- func Err(err error)
- func Errf(format string, v ...interface{})
- func Fatal(err error)
- func Info(err error)
- func Infof(format string, v ...interface{})
- func Init(cfg Config) error
- func InitWithDefaults(logLevel byte)
- func Log(text string)
- func Panic(err error)
- func Print(msg string)
- func RemoveOutput(writer io.Writer)
- func ToDiscord(channel HookChannel, text string) error
- func Trace(err error)
- func Tracef(format string, v ...interface{})
- func Warn(err error)
- func Warnf(format string, v ...interface{})
- type AllowedMentions
- type Author
- type Config
- type Embed
- type Field
- type Footer
- type HookChannel
- type Image
- type LogEntry
- type LogType
- type Message
- type MongoDBLogger
- func (m *MongoDBLogger) Close() error
- func (m *MongoDBLogger) CountLogsByLevel(level string, dateStr string) (int64, error)
- func (m *MongoDBLogger) GetLogs(filter bson.M, limit int, skip int) ([]LogEntry, error)
- func (m *MongoDBLogger) GetLogsByLevel(level string, limit int, skip int) ([]LogEntry, error)
- func (m *MongoDBLogger) GetLogsByTimeRange(start, end time.Time, limit int, skip int) ([]LogEntry, error)
- func (m *MongoDBLogger) GetLogsByType(logType LogType, limit int, skip int) ([]LogEntry, error)
- func (m *MongoDBLogger) Write(p []byte) (n int, err error)
- type OutputType
- type Thumbnail
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // DefaultOutputs specifies the default logging outputs DefaultOutputs = []OutputType{ConsoleOutput} )
Functions ¶
func InitWithDefaults ¶
func InitWithDefaults(logLevel byte)
InitWithDefaults initializes the logger with default console output
func RemoveOutput ¶
RemoveOutput removes an output writer from the logger
func ToDiscord ¶
func ToDiscord(channel HookChannel, text string) error
Types ¶
type AllowedMentions ¶
type Config ¶
type Config struct {
Level zerolog.Level
Outputs []OutputType
MongoClient *mongo.Client // Cliente de MongoDB existente
MongoDatabase string
MongoCollection string
}
Config holds the logging configuration
type Embed ¶
type Embed struct {
Title *string `json:"title,omitempty"`
Url *string `json:"url,omitempty"`
Description *string `json:"description,omitempty"`
Color *string `json:"color,omitempty"`
Author *Author `json:"author,omitempty"`
Fields *[]Field `json:"fields,omitempty"`
Thumbnail *Thumbnail `json:"thumbnail,omitempty"`
Image *Image `json:"image,omitempty"`
}
type HookChannel ¶
type HookChannel string
var ( HookChannelNone HookChannel = "" HookChannelPro HookChannel = HookChannel(os.Getenv("DISCORD_CHANNEL_PRO")) HookChannelDemo HookChannel = HookChannel(os.Getenv("DISCORD_CHANNEL_DEMO")) HookChannelODM HookChannel = HookChannel(os.Getenv("DISCORD_CHANNEL_ODM")) HookChannelLog HookChannel = HookChannel(os.Getenv("DISCORD_CHANNEL_LOG")) HookChannelErr HookChannel = HookChannel(os.Getenv("DISCORD_CHANNEL_ERR")) HookChannelAgtech HookChannel = HookChannel(os.Getenv("DISCORD_CHANNEL_AGTECH")) )
type LogEntry ¶
type LogEntry struct {
Level string `bson:"level"`
Type LogType `bson:"type"`
Message string `bson:"message"`
Error string `bson:"error,omitempty"`
Timestamp time.Time `bson:"timestamp"`
Fields bson.M `bson:"fields,omitempty"`
}
LogEntry represents a log entry in MongoDB
type Message ¶
type Message struct {
Username *string `json:"username,omitempty"`
AvatarUrl *string `json:"avatar_url,omitempty"`
Content *string `json:"content,omitempty"`
Embeds *[]Embed `json:"embeds,omitempty"`
AllowedMentions *AllowedMentions `json:"allowed_mentions,omitempty"`
}
type MongoDBLogger ¶
type MongoDBLogger struct {
// contains filtered or unexported fields
}
func NewMongoDBLogger ¶
func NewMongoDBLogger(client *mongo.Client, database, collection string) *MongoDBLogger
NewMongoDBLogger creates a new MongoDB logger using an existing MongoDB client
func (*MongoDBLogger) Close ¶
func (m *MongoDBLogger) Close() error
Close closes the MongoDB connection
func (*MongoDBLogger) CountLogsByLevel ¶
func (m *MongoDBLogger) CountLogsByLevel(level string, dateStr string) (int64, error)
CountLogsByLevel counts logs filtered by level (case-insensitive)
func (*MongoDBLogger) GetLogsByLevel ¶
GetLogsByLevel retrieves logs filtered by level (case-insensitive)
func (*MongoDBLogger) GetLogsByTimeRange ¶
func (m *MongoDBLogger) GetLogsByTimeRange(start, end time.Time, limit int, skip int) ([]LogEntry, error)
GetLogsByTimeRange retrieves logs within a specific time range
func (*MongoDBLogger) GetLogsByType ¶
GetLogsByType retrieves logs filtered by type
type OutputType ¶
type OutputType string
OutputType defines the type of logging output
const ( // ConsoleOutput sends logs to console ConsoleOutput OutputType = "console" // MongoDBOutput sends logs to MongoDB MongoDBOutput OutputType = "mongodb" )
Click to show internal directories.
Click to hide internal directories.