1 /* Datamanager-specific logging methods. */
6 "git.curoverse.com/arvados.git/sdk/go/logger"
13 // Useful to call at the begining of execution to log info about the
15 func LogRunInfo(arvLogger *logger.Logger) {
18 arvLogger.Update(func(p map[string]interface{}, e map[string]interface{}) {
19 runInfo := logger.GetOrCreateMap(p, "run_info")
20 runInfo["started_at"] = now
21 runInfo["args"] = os.Args
22 hostname, err := os.Hostname()
24 runInfo["hostname_error"] = err.Error()
26 runInfo["hostname"] = hostname
28 runInfo["pid"] = os.Getpid()
33 // A LogMutator that records the current memory usage. This is most useful as a logger write hook.
34 func LogMemoryAlloc(p map[string]interface{}, e map[string]interface{}) {
35 runInfo := logger.GetOrCreateMap(p, "run_info")
36 var memStats runtime.MemStats
37 runtime.ReadMemStats(&memStats)
38 runInfo["memory_bytes_in_use"] = memStats.Alloc
39 runInfo["memory_bytes_reserved"] = memStats.Sys
42 func FatalWithMessage(arvLogger *logger.Logger, message string) {
44 arvLogger.FinalUpdate(func(p map[string]interface{}, e map[string]interface{}) {
46 runInfo := logger.GetOrCreateMap(p, "run_info")
47 runInfo["finished_at"] = time.Now()