Added ForceRecord() method to enable writing remaining log changes before exiting.
authormishaz <misha@curoverse.com>
Fri, 9 Jan 2015 04:11:29 +0000 (04:11 +0000)
committerTom Clegg <tom@curoverse.com>
Fri, 13 Feb 2015 21:23:54 +0000 (16:23 -0500)
sdk/go/logger/logger.go
services/datamanager/collection/collection.go

index 038482dda885704d9b9bb09d209913530c96b57a..294ba9214e0ed8fb485d3f3cc76adb94b433a8e2 100644 (file)
@@ -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 {
index 7e94a116181fed701a84020e37cbe15e1942b174..dd37377c063a512e762f12c00f56274fd100fd71 100644 (file)
@@ -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)
                }