Added Ping method to the logger class
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
package fluentd
|
package fluentd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
@@ -38,11 +37,15 @@ func (l *Logger) Log(format string, v ...any) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (l *Logger) Ping() error {
|
func (l *Logger) Ping() error {
|
||||||
if l.fluent.RequestAck {
|
mapData := map[string]string{
|
||||||
return nil
|
"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 {
|
func (l *Logger) Close() error {
|
||||||
|
|||||||
Reference in New Issue
Block a user