@cryptotaxi247 / kubo / commits / c89b5ce82

wip Loggable func

Brian Tiger Chow committed Jan 18, 2015 at 15:09 UTC c89b5ce8244807a267280d72c550fd8937c5a7c4
1 file changed +16
thirdparty/eventlog/loggable.go
+16
@@ -10,3 +10,19 @@ type LoggableMap map[string]interface{}
10 func (l LoggableMap) Loggable() map[string]interface{} {
11 return l
12 }
13 +
14 +// Loggable converts a func into a Loggable
15 +type LoggableF func() map[string]interface{}
16 +
17 +func (l LoggableF) Loggable() map[string]interface{} {
18 + return l()
19 +}
20 +
21 +func Deferred(key string, f func() string) Loggable {
22 + function := func() map[string]interface{} {
23 + return map[string]interface{}{
24 + key: f(),
25 + }
26 + }
27 + return LoggableF(function)
28 +}