Browse Source

[desktop] Log errors in file_reporter

Erick Tryzelaar 10 năm trước cách đây
mục cha
commit
f2a7bda452
1 tập tin đã thay đổi với 7 bổ sung4 xóa
  1. 7 4
      desktop/core/src/desktop/lib/metrics/file_reporter.py

+ 7 - 4
desktop/core/src/desktop/lib/metrics/file_reporter.py

@@ -33,10 +33,12 @@ class FileReporter(Reporter):
 
   def report_now(self, registry=None, timestamp=None):
     dirname = os.path.dirname(self.location)
-    try:
-      os.makedirs(dirname)
-    except OSError:
-      pass
+
+    if not os.path.exist(dirname):
+      try:
+        os.makedirs(dirname)
+      except OSError, e:
+        LOG.error('failed to make the directory %s: %s' % (dirname, e))
 
     # Write the metrics to a temporary file, then atomically
     # rename the file to the real location.
@@ -51,6 +53,7 @@ class FileReporter(Reporter):
 
       os.rename(f.name, self.location)
     except Exception:
+      LOG.exception('failed to write metrics to file')
       os.remove(f.name)
       raise