A simple and lightweight logging library for Go.
- Multiple log levels (DEBUG, INFO, WARN, ERROR)
- Colored log output for better readability
- Displays timestamp, file name, and line number
- Easy to set up and use
- Webhook support (Discord)
go get github.com/solgitae/loggerHere is a simple example of how to use logger:
package main
import (
"github.com/solgitae/logger/model"
)
func main() {
// Set the minimum log level.
// Only logs with this level or higher will be printed.
logger.Default("DEBUG")
logger.Info("This is an info message.")
logger.Error("This is an error message.")
logger.Debug("This message will not be printed.")
logger.Warn("This is a warning message.")
}The following log levels are available:
DEBUG: For detailed debugging information.INFO: For general informational messages.WARN: For warnings that might indicate a problem.ERROR: For errors that have occurred.
You can set the minimum log level using the logger.Default() function. For example, if you set the level to INFO, DEBUG messages will not be printed.
The log output is formatted as follows:
[<LEVEL>][<file>:<line>][<timestamp>] <message>
<LEVEL>: The log level (e.g., INFO, ERROR).<file>:<line>: The file name and line number where the log was called.<timestamp>: The time when the log was created.<message>: The log message.
logger supports sending log messages to webhooks. Currently, Discord is supported.
To send log messages to a Discord channel, you need to create a DiscordNotifier and add it to the logger.
package main
import (
"github.com/solgitae/logger/model"
)
func main() {
logger.Default("DEBUG")
logger.Info("This message will be sent to Discord.")
}