🤔
What is this?
Well this is a simple logger created with some tools and colors
👀
How see this in action ?
- Terminal color action
- Json file generator
⌨️
How install this ?
go get github.com/TeoDev1611/batman
👌
Examples
package main
import (
"github.com/TeoDev1611/batman/log" // Import the log library
)
func main() {
log.Config.AppName = "YourAppName" // Add the app name for the folder to create the logs
log.Config.FileToLog = "filetolog.log" // Add the name for the file to write the logs ( JSON FORMAT )
err := log.Init() // Init the app
if err != nil {
panic(err) // Check the errors
}
log.Info("an example info") // Make a info level logger
log.Warning("an example warning") // Make a warning logger
log.Error("an example error") // Make a error logger
log.Fatal("an example fatal") // Make a fatal
print("this will be not printed") // WHY THIS NOT PRINT ( Make a os exit status 2 for the fatal)
// DISABLE ?? Check the customization opts
}
- Customization examples
package main
import (
"github.com/TeoDev1611/batman/log" // Import the log library
)
func init(){
log.LogOpts.Error = "CUSTOM_KEY_ERROR" // Custom the key for the json file in the error level DEFAULT: ERROR
log.LogOpts.Info = "CUSTOM_KEY_INFO" // Custom the key for the json file in the info level DEFAULT: INFO
log.LogOpts.Warning = "CUSTOM_KEY_WARN" // Custom the key for the json file in the warn level DEFAULT: WARN
log.LogOpts.Fatal = "CUSTOM_KEY_FATAL" // Custom the key for the json file in the fatal level DEFAULT: FATAL
log.LogOpts.ErrorExit = true // Exit the program with 2 code in the error logs DEFAULT: false
log.LogOpts.FatalExit = true // Exit the program with 2 code in the fatal logs DEFAULT: true
}
📚
Steps to contribute
- Make a Fork to this repository
- Make a branch with the feature to add
- Use the conventional commits guide more information here
- Make a pull request with a explanation what you changes or features
- Review your pull request
- Merge the pull request or request changes
- Done!
😃
📣
Credits
Special thanks to Ashley Willis were i stracted the gopher batman image here
Made with