12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- package hiedabke_writer
- import (
- "encoding/json"
- "fmt"
- "time"
- )
- type HiedaComplexLogFormatter interface {
- FormatHiedaComplexLog(module string, level string, data map[string]string) string
- }
- type HiedaStringLogFormatter interface {
- FormatHiedaStringLog(module string, level string, data string) string
- }
- type HiedaComplexLogJsonFormatter struct {
- }
- func (f *HiedaComplexLogJsonFormatter) FormatHiedaComplexLog(module string, level string, data map[string]string) string {
- jd, err := json.Marshal(data)
- if err != nil {
- return "{}"
- }
- ps := string(jd)
- return fmt.Sprintf("[%s] <%s> %s", module, level, ps)
- }
- 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)
- }
|