Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b829092503 | |||
| e16021ee49 |
@@ -1,9 +1,9 @@
|
||||
package fluentd
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
"time"
|
||||
|
||||
"github.com/fluent/fluent-logger-golang/fluent"
|
||||
)
|
||||
@@ -15,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 {
|
||||
@@ -38,11 +38,15 @@ func (l *Logger) Log(format string, v ...any) {
|
||||
}
|
||||
|
||||
func (l *Logger) Ping() error {
|
||||
if l.fluent.RequestAck {
|
||||
return nil
|
||||
mapData := map[string]string{
|
||||
"message": "Checking is Fluentd alive",
|
||||
}
|
||||
err := l.fluent.Post(l.appName, mapData)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return errors.New("Logger service is unavailable")
|
||||
return nil
|
||||
}
|
||||
|
||||
func (l *Logger) Close() error {
|
||||
|
||||
Reference in New Issue
Block a user