-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathlogger.go
More file actions
47 lines (37 loc) · 709 Bytes
/
logger.go
File metadata and controls
47 lines (37 loc) · 709 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package transaction
// Core
// Logger
// Copyright © 2017-2018 Eduard Sesigin. All rights reserved. Contacts: <claygod@yandex.ru>
import (
"fmt"
lg "log"
)
/*
logger - prints error messages to the console
*/
type logger map[string]interface{}
/*
log - return new logger
*/
func log(msg string) logger {
return logger{"": msg} //make(logger)
}
/*
context - add context to the log
*/
func (l logger) context(k string, v interface{}) logger {
l[k] = v
return l
}
func (l logger) send() {
out := ""
for k, value := range l {
switch v := value.(type) {
case int, int64:
out += fmt.Sprintf("%s: %d. ", k, v)
case string:
out += fmt.Sprintf("%s: %s. ", k, v)
}
}
go lg.Print(out)
}