@rivascva/dt-idl 1.1.75 → 1.1.77
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/go/log/log.go +7 -7
- package/go/log/utils.go +4 -0
- package/package.json +1 -1
package/go/log/log.go
CHANGED
|
@@ -36,26 +36,26 @@ type Log struct {
|
|
|
36
36
|
func NewLog() *Log {
|
|
37
37
|
return &Log{
|
|
38
38
|
kvs: make(map[string]any, 10),
|
|
39
|
-
info: log.New(os.Stdout, "",
|
|
40
|
-
warn: log.New(os.Stdout, "",
|
|
41
|
-
error: log.New(os.Stdout, "",
|
|
39
|
+
info: log.New(os.Stdout, "", 0),
|
|
40
|
+
warn: log.New(os.Stdout, "", 0),
|
|
41
|
+
error: log.New(os.Stdout, "", 0),
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
func (l *Log) Info(m any) {
|
|
46
|
-
l.info.Println(toJson(m, l.kvs, "
|
|
46
|
+
l.info.Println(toJson(m, l.kvs, "info"))
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
func (l *Log) Warn(m any) {
|
|
50
|
-
l.warn.Println(toJson(m, l.kvs, "
|
|
50
|
+
l.warn.Println(toJson(m, l.kvs, "warn"))
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
func (l *Log) Error(m any) {
|
|
54
|
-
l.error.Println(toJson(m, l.kvs, "
|
|
54
|
+
l.error.Println(toJson(m, l.kvs, "error"))
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
func (l *Log) Fatal(m any) {
|
|
58
|
-
l.error.Fatal(toJson(m, l.kvs, "
|
|
58
|
+
l.error.Fatal(toJson(m, l.kvs, "error"))
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
func (l *Log) With(kvs ...any) Logger {
|
package/go/log/utils.go
CHANGED
|
@@ -3,6 +3,7 @@ package log
|
|
|
3
3
|
import (
|
|
4
4
|
"encoding/json"
|
|
5
5
|
"maps"
|
|
6
|
+
"time"
|
|
6
7
|
)
|
|
7
8
|
|
|
8
9
|
// toJson converts the message and key-value pairs to a JSON string.
|
|
@@ -15,6 +16,9 @@ func toJson(m any, kvs map[string]any, level string) string {
|
|
|
15
16
|
// add the log level
|
|
16
17
|
out["level"] = level
|
|
17
18
|
|
|
19
|
+
// add the timestamp
|
|
20
|
+
out["timestamp"] = time.Now().UTC().Format(time.RFC3339)
|
|
21
|
+
|
|
18
22
|
// marshal the map to a JSON byte array
|
|
19
23
|
data, err := json.Marshal(out)
|
|
20
24
|
if err != nil {
|