This tool provides a custom logging solution for Go applications using the logify
package. It supports various log levels such as INFO, TEST, DEBUG, FATAL, ERROR, and WARN, and allows for custom log messages with specified colors and formats. The logger follows the Singleton pattern to ensure a consistent logging instance throughout the application.
This logging package is versatile, suitable for CLI tools, security tools, web servers, and more, offering robust and customizable logging capabilities.
- Log Levels: INFO, TEST, DEBUG, FATAL, ERROR, WARN.
- Custom Logger: Custom log messages with specified colors and formats.
- Singleton Pattern: Single logger instance throughout the application.
Install the logify
package using go get
:
go get github.com/cyinnove/logify@latest
Import the package in your Go application:
import (
log "github.com/cyinnove/logify"
)
Example of basic logging functionality:
package main
import (
log "github.com/cyinnove/logify"
)
func main() {
path := "docs/example.go"
log.Msg().Warn(path)
}
Creating custom log messages with specified colors and formats:
package main
import (
log "github.com/cyinnove/logify"
)
func main() {
path := "examples/example.go"
log.Msg().Warn(path)
CustomLogger(log.Red, "Custom", "This is a custom log message with color %s", "Red")
}
func CustomLogger(color log.Color, holder, message string, args ...interface{}) {
formatter := log.Formatter{}
formatter.SetHolder(holder)
formatter.SetMessage(message, args...)
formatter.SetColor(color)
formatter.Log()
}
The logger supports the following log levels:
- INFO
- TEST
- DEBUG
- FATAL
- ERROR
- WARN
These levels help categorize and filter log messages based on severity.
The logger ensures a single instance across the entire application, maintaining consistency and avoiding issues with multiple instances.
Contributions are welcome! Submit a pull request or open an issue for suggestions or bug reports.
This project is licensed under the MIT License. See the LICENSE file for details.