From: mishaz Date: Fri, 9 Jan 2015 04:11:29 +0000 (+0000) Subject: Added ForceRecord() method to enable writing remaining log changes before exiting. X-Git-Tag: 1.1.0~1505^2~56 X-Git-Url: https://git.arvados.org/arvados.git/commitdiff_plain/b14bc80d764b85a6ddfed32198b2144b5adf2637 Added ForceRecord() method to enable writing remaining log changes before exiting. --- diff --git a/sdk/go/logger/logger.go b/sdk/go/logger/logger.go index 038482dda8..294ba9214e 100644 --- a/sdk/go/logger/logger.go +++ b/sdk/go/logger/logger.go @@ -107,6 +107,13 @@ func (l *Logger) Record() { l.lock.Unlock() } +// Similar to Record, but forces a write without respecting the +// MinimumWriteInterval. This is useful if you know that you're about +// to quit (e.g. if you discovered a fatal error). +func (l *Logger) ForceRecord() { + l.write() + l.lock.Unlock() +} // Whether enough time has elapsed since the last write. func (l *Logger) writeAllowedNow() bool { diff --git a/services/datamanager/collection/collection.go b/services/datamanager/collection/collection.go index 7e94a11618..dd37377c06 100644 --- a/services/datamanager/collection/collection.go +++ b/services/datamanager/collection/collection.go @@ -58,7 +58,7 @@ func init() { flag.StringVar(&heap_profile_filename, "heap-profile", "", - "File to write the heap profiles to.") + "File to write the heap profiles to. Leave blank to skip profiling.") } // // Methods to implement util.SdkListResponse Interface @@ -146,6 +146,11 @@ func GetCollections(params GetCollectionsParams) (results ReadCollections) { var collections SdkCollectionList err := params.Client.List("collections", sdkParams, &collections) if err != nil { + if params.Logger != nil { + properties,_ := params.Logger.Edit() + properties["FATAL"] = err.Error() + params.Logger.Record() + } log.Fatalf("error querying collections: %+v", err) }