aboutsummaryrefslogtreecommitdiffstats
path: root/logger/loggers.go
diff options
context:
space:
mode:
authorTaylor Gerring <taylor.gerring@gmail.com>2015-02-11 02:21:13 +0800
committerTaylor Gerring <taylor.gerring@gmail.com>2015-02-11 02:21:13 +0800
commitd53e5646ecfce75790fea45a1ee552494ef88668 (patch)
treef00d3e151227b4e31be2293401692927473bc17e /logger/loggers.go
parentc14900dbb007af8aefc5f5583f3c17a613c66802 (diff)
downloaddexon-d53e5646ecfce75790fea45a1ee552494ef88668.tar
dexon-d53e5646ecfce75790fea45a1ee552494ef88668.tar.gz
dexon-d53e5646ecfce75790fea45a1ee552494ef88668.tar.bz2
dexon-d53e5646ecfce75790fea45a1ee552494ef88668.tar.lz
dexon-d53e5646ecfce75790fea45a1ee552494ef88668.tar.xz
dexon-d53e5646ecfce75790fea45a1ee552494ef88668.tar.zst
dexon-d53e5646ecfce75790fea45a1ee552494ef88668.zip
Use strongly-typed objects
Diffstat (limited to 'logger/loggers.go')
-rw-r--r--logger/loggers.go17
1 files changed, 4 insertions, 13 deletions
diff --git a/logger/loggers.go b/logger/loggers.go
index cd465ce87..36bc38116 100644
--- a/logger/loggers.go
+++ b/logger/loggers.go
@@ -16,7 +16,6 @@ import (
"encoding/json"
"fmt"
"os"
- "time"
)
type LogLevel uint32
@@ -121,20 +120,12 @@ func NewJsonLogger() *JsonLogger {
return &JsonLogger{}
}
-func (logger *JsonLogger) LogJson(msgname string, dict map[string]interface{}) {
- if _, ok := dict["ts"]; !ok {
- dict["ts"] = time.Now().Local().Format(time.RFC3339Nano)
- }
-
- // FIX
- if _, ok := dict["level"]; !ok {
- dict["level"] = "debug"
- }
-
+func (logger *JsonLogger) LogJson(msgname string, v interface{}) {
obj := map[string]interface{}{
- msgname: dict,
+ msgname: v,
}
jsontxt, _ := json.Marshal(obj)
- logMessageC <- message{JsonLevel, fmt.Sprintf("%s", jsontxt)}
+ logMessageC <- message{JsonLevel, string(jsontxt)}
+
}