MyLog
MyLog is a Go package designed to enable fast logging via Kafka.
Installation
To use MyLog in your Go project, you can simply run:
go get github.com/heyitsfranky/MyLog@latest
Usage
Here's a basic example of how to use MyLog:
package main
import (
"fmt"
"github.com/heyitsfranky/MyLog"
)
func main() {
configFilePath := "path/to/your/config.yaml"
// Initialize MyLog with the configuration file
if err := MyLog.Init(configFilePath); err != nil {
fmt.Printf("Error initializing MyLog: %s\n", err)
return
}
// Create a intricate log event asynchronously
body := map[string]interface{}{"msg": "hello world!", "id": 42}
MyLog.CreateEvent(body, "main()", 0, true)
// (or synchronously)
MyLog.CreateEvent(body, "main()", 0, false)
// Create predefined log events asynchronously
MyLog.CreateInfoEvent("This is an informational message", "MyPackage::main()")
MyLog.CreateWarningEvent("This is a warning message", "somefn()")
MyLog.CreateErrorEvent("This is an error message", "foobar()")
MyLog.CreateCriticalEvent("This is a critical error message", "MyClass.hello()")
}
Configuration
To load the initial settings for event communication via kafka, a configuration file must be given that contains:
client-origin: your-app-name,
kafka-broker: localhost:9092,
An up-to-date template can always be found under 'configs/config.yaml'.
License
This package is distributed under the MIT License.
Feel free to contribute or report issues on GitHub.
Happy coding!