Commits

Stefano Rivera committed 5b250a5

Make dropping log files optional

Comments (0)

Files changed (1)

dogslow/__init__.py

             output = output.encode('utf-8')
 
             # dump to file:
-            fd, fn = tempfile.mkstemp(prefix='slow_request_', suffix='.log',
-                                      dir=getattr(settings, 'DOGSLOW_OUTPUT',
-                                              tempfile.gettempdir()))
-            try:
-                os.write(fd, output)
-            finally:
-                os.close(fd)
+            write_log = getattr(settings, 'DOGSLOW_WRITE_LOG', True)
+            if write_log:
+                fd, fn = tempfile.mkstemp(prefix='slow_request_',
+                                          suffix='.log',
+                                          dir=getattr(settings,
+                                                      'DOGSLOW_OUTPUT',
+                                                      tempfile.gettempdir()))
+                try:
+                    os.write(fd, output)
+                finally:
+                    os.close(fd)
 
             # and email?
             email_to = getattr(settings, 'DOGSLOW_EMAIL_TO', None)