Stefano Rivera avatar 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)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.