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 := make(map[string]interface{})
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()
29 p["run_info"] = runInfo
34 // A LogMutator that records the current memory usage. This is most useful as a logger write hook.
36 // Assumes we already have a map named "run_info" in properties. LogRunInfo() can create such a map for you if you call it.
37 func LogMemoryAlloc(p map[string]interface{}, e map[string]interface{}) {
38 runInfo := p["run_info"].(map[string]interface{})
39 var memStats runtime.MemStats
40 runtime.ReadMemStats(&memStats)
41 runInfo["alloc_bytes_in_use"] = memStats.Alloc
44 func FatalWithMessage(arvLogger *logger.Logger, message string) {
46 arvLogger.FinalUpdate(func(p map[string]interface{}, e map[string]interface{}) {
48 p["run_info"].(map[string]interface{})["finished_at"] = time.Now()