Repository: readthedocs/readthedocs.org

Issue:
Add datetime to LOG_FORMAT
With the new branch (https://github.com/rtfd/readthedocs.org/blob/fix-logging/readthedocs/settings/base.py#L336) we have a very good logging shine and working, but it's missing the datetime.

```
readthedocs.doc_builder.environments[31528]: INFO (Build) [tornado:latest] Build finished [readthedocs.doc_builder.environments:540]
readthedocs.core.views.hooks[31528]: INFO (Version build) Building tornado:latest [readthedocs.core.views.hooks:55]
readthedocs.core.views.hooks[31528]: INFO (Version build) Building tornado:latest [readthedocs.core.views.hooks:55]
readthedocs.api.client[32396]: DEBUG Using slumber with user test, pointed at http://localhost:8000 [readthedocs.api.client:24]
readthedocs.api.client[32396]: DEBUG Using slumber with user test, pointed at http://localhost:8000 [readthedocs.api.client:24]
readthedocs.restapi.client[32396]: DEBUG Using slumber v2 with user test, pointed at http://localhost:8000 [readthedocs.restapi.client:46]
readthedocs.restapi.client[32396]: DEBUG Using slumber v2 with user test, pointed at http://localhost:8000 [readthedocs.restapi.client:46]
```

So, I suggest to change it to something like this to include the datetime and remove the duplcated `(name)s`:

    %(asctime)s - [%(name)s:%(lineno)s][%(process)d]: %(levelname)s %(message)s

@agjohnson we should probably add this to your branch.


Discussion:

Resolving patch:
diff --git a/readthedocs/settings/base.py b/readthedocs/settings/base.py
--- a/readthedocs/settings/base.py
+++ b/readthedocs/settings/base.py
@@ -333,132 +333,39 @@ def INSTALLED_APPS(self):  # noqa
     SILENCED_SYSTEM_CHECKS = ['fields.W342']
 
     # Logging
-    LOG_FORMAT = "[%(asctime)s] %(levelname)s [%(name)s:%(lineno)s] %(message)s"
+    LOG_FORMAT = '%(name)s:%(lineno)s[%(process)d]: %(levelname)s %(message)s'
     LOGGING = {
         'version': 1,
         'disable_existing_loggers': True,
         'formatters': {
-            'standard': {
+            'default': {
                 'format': LOG_FORMAT,
-                'datefmt': "%d/%b/%Y %H:%M:%S"
+                'datefmt': '%d/%b/%Y %H:%M:%S',
             },
         },
-        'filters': {
-            'require_debug_false': {
-                '()': 'django.utils.log.RequireDebugFalse'
-            }
-        },
         'handlers': {
-            'null': {
-                'level': 'DEBUG',
-                'class': 'logging.NullHandler',
-            },
-            'exceptionlog': {
-                'level': 'DEBUG',
-                'class': 'logging.handlers.RotatingFileHandler',
-                'filename': os.path.join(LOGS_ROOT, "exceptions.log"),
-                'formatter': 'standard',
-            },
-            'errorlog': {
+            'console': {
                 'level': 'INFO',
-                'class': 'logging.handlers.RotatingFileHandler',
-                'filename': os.path.join(LOGS_ROOT, "rtd.log"),
-                'formatter': 'standard',
-            },
-            'postcommit': {
-                'level': 'DEBUG',
-                'class': 'logging.handlers.RotatingFileHandler',
-                'filename': os.path.join(LOGS_ROOT, "postcommit.log"),
-                'formatter': 'standard',
-            },
-            'middleware': {
-                'level': 'DEBUG',
-                'class': 'logging.handlers.RotatingFileHandler',
-                'filename': os.path.join(LOGS_ROOT, "middleware.log"),
-                'formatter': 'standard',
+                'class': 'logging.StreamHandler',
+                'formatter': 'default'
             },
-            'restapi': {
+            'debug': {
                 'level': 'DEBUG',
                 'class': 'logging.handlers.RotatingFileHandler',
-                'filename': os.path.join(LOGS_ROOT, "api.log"),
-                'formatter': 'standard',
-            },
-            'db': {
-                'level': 'INFO',
-                'class': 'logging.handlers.RotatingFileHandler',
-                'filename': os.path.join(LOGS_ROOT, "db.log"),
-                'formatter': 'standard',
-            },
-            'search': {
-                'level': 'INFO',
-                'class': 'logging.handlers.RotatingFileHandler',
-                'filename': os.path.join(LOGS_ROOT, "search.log"),
-                'formatter': 'standard',
-            },
-            'mail_admins': {
-                'level': 'ERROR',
-                'filters': ['require_debug_false'],
-                'class': 'django.utils.log.AdminEmailHandler',
-            },
-            'console': {
-                'level': ('INFO', 'DEBUG')[DEBUG],
-                'class': 'logging.StreamHandler',
-                'formatter': 'standard'
+                'filename': 'debug.log',
+                'formatter': 'default',
             },
         },
         'loggers': {
-            'django': {
-                'handlers': ['console', 'errorlog'],
-                'propagate': True,
-                'level': 'WARN',
-            },
-            'django.db.backends': {
-                'handlers': ['db'],
-                'level': 'DEBUG',
-                'propagate': False,
-            },
-            'readthedocs.core.views.post_commit': {
-                'handlers': ['postcommit'],
-                'level': 'DEBUG',
-                'propagate': False,
-            },
-            'core.middleware': {
-                'handlers': ['middleware'],
-                'level': 'DEBUG',
-                'propagate': False,
-            },
-            'restapi': {
-                'handlers': ['restapi'],
+            'readthedocs': {
+                'handlers': ['debug', 'console'],
                 'level': 'DEBUG',
-                'propagate': False,
-            },
-            'django.request': {
-                'handlers': ['exceptionlog'],
-                'level': 'ERROR',
-                'propagate': False,
-            },
-            'readthedocs.projects.views.public.search': {
-                'handlers': ['search'],
-                'level': 'DEBUG',
-                'propagate': False,
-            },
-            'search': {
-                'handlers': ['search'],
-                'level': 'DEBUG',
-                'propagate': False,
+                'propagate': True,
             },
-            # Uncomment if you want to see Elasticsearch queries in the console.
-            # 'elasticsearch.trace': {
-            #     'level': 'DEBUG',
-            #     'handlers': ['console'],
-            # },
-
-            # Default handler for everything that we're doing. Hopefully this
-            # doesn't double-print the Django things as well. Not 100% sure how
-            # logging works :)
             '': {
-                'handlers': ['console', 'errorlog'],
-                'level': 'INFO',
+                'handlers': ['debug', 'console'],
+                'level': 'DEBUG',
+                'propagate': True,
             },
-        }
+        },
     }
diff --git a/readthedocs/settings/dev.py b/readthedocs/settings/dev.py
--- a/readthedocs/settings/dev.py
+++ b/readthedocs/settings/dev.py
@@ -51,6 +51,12 @@ def DATABASES(self):  # noqa
         'test:8000',
     )
 
+    @property
+    def LOGGING(self):  # noqa - avoid pep8 N802
+        logging = super(CommunityDevSettings, self).LOGGING
+        logging['formatters']['default']['format'] = '[%(asctime)s] ' + self.LOG_FORMAT
+        return logging
+
 
 CommunityDevSettings.load_settings(__name__)
 


Test patch: