Compare commits

..

4 Commits

Author SHA1 Message Date
b829092503 Added WriteTimeout (100ms) 2025-10-12 19:20:48 +02:00
e16021ee49 Added Ping method to the logger class 2025-10-12 19:17:17 +02:00
69797a214f Added Ping method to the logger class 2025-10-12 17:53:37 +02:00
53e2d49e36 Fix .env file name 2025-10-12 16:38:46 +02:00
2 changed files with 17 additions and 4 deletions

View File

@@ -9,7 +9,7 @@ import (
var ErrLoadingEnvs error
func init() {
ErrLoadingEnvs = godotenv.Load(".env.local", ".env")
ErrLoadingEnvs = godotenv.Load()
}
func GetEnv(name string, defVal string) string {

View File

@@ -3,6 +3,7 @@ package fluentd
import (
"fmt"
"log"
"time"
"github.com/fluent/fluent-logger-golang/fluent"
)
@@ -14,9 +15,9 @@ type Logger struct {
func NewLogger(appName, fHost string, fPort int) (*Logger, error) {
config := fluent.Config{
FluentHost: fHost,
FluentPort: fPort,
// WriteTimeout: -1,
FluentHost: fHost,
FluentPort: fPort,
WriteTimeout: 100 * time.Millisecond,
}
fluent, err := fluent.New(config)
if err != nil {
@@ -36,6 +37,18 @@ func (l *Logger) Log(format string, v ...any) {
}
}
func (l *Logger) Ping() error {
mapData := map[string]string{
"message": "Checking is Fluentd alive",
}
err := l.fluent.Post(l.appName, mapData)
if err != nil {
return err
}
return nil
}
func (l *Logger) Close() error {
return l.fluent.Close()
}