|
@@ -3,6 +3,7 @@ package hiedabke_writer
|
|
|
import (
|
|
|
"encoding/json"
|
|
|
"fmt"
|
|
|
+ "time"
|
|
|
)
|
|
|
|
|
|
type HiedaComplexLogFormatter interface {
|
|
@@ -31,3 +32,24 @@ type HiedaStringLogDefaultFormatter struct {
|
|
|
func (f *HiedaStringLogDefaultFormatter) FormatHiedaStringLog(module string, level string, data string) string {
|
|
|
return fmt.Sprintf("[%s] <%s> %s", module, level, data)
|
|
|
}
|
|
|
+
|
|
|
+type HiedaComplexLogJsonWithTimeFormatter struct {
|
|
|
+}
|
|
|
+
|
|
|
+func (f *HiedaComplexLogJsonWithTimeFormatter) FormatHiedaComplexLog(module string, level string, data map[string]string) string {
|
|
|
+ jd, err := json.Marshal(data)
|
|
|
+ if err != nil {
|
|
|
+ return "{}"
|
|
|
+ }
|
|
|
+ ps := string(jd)
|
|
|
+ tstr := time.Now().Format(time.RFC3339Nano)
|
|
|
+ return fmt.Sprintf("{%s}[%s] <%s> %s", tstr, module, level, ps)
|
|
|
+}
|
|
|
+
|
|
|
+type HiedaStringLogDefaultWithTimeFormatter struct {
|
|
|
+}
|
|
|
+
|
|
|
+func (f *HiedaStringLogDefaultWithTimeFormatter) FormatHiedaStringLog(module string, level string, data string) string {
|
|
|
+ tstr := time.Now().Format(time.RFC3339Nano)
|
|
|
+ return fmt.Sprintf("{%s}[%s] <%s> %s", tstr, module, level, data)
|
|
|
+}
|