Skip to content
Browse files

Add source to log lines.

  • Loading branch information...
1 parent faca9a7 commit cb6e7081cd7518f011917eda623f224adcb67e75 @oremj oremj committed
Showing with 9 additions and 3 deletions.
  1. +9 −3 funfactory/log_settings.py
View
12 funfactory/log_settings.py
@@ -1,5 +1,6 @@
import logging
import logging.handlers
+import socket
from django.conf import settings
@@ -17,6 +18,11 @@ def emit(self, record):
':%(pathname)s:%(lineno)s')
use_syslog = settings.HAS_SYSLOG and not settings.DEBUG
+if use_syslog:
+ hostname = socket.gethostname()
+else:
+ hostname = 'localhost'
+
cfg = {
'version': 1,
'filters': {},
@@ -29,8 +35,9 @@ def emit(self, record):
'prod': {
'()': commonware.log.Formatter,
'datefmt': '%H:%M:%s',
- 'format': '%s: [%%(REMOTE_ADDR)s] %s' % (settings.SYSLOG_TAG,
- base_fmt),
+ 'format': '%s %s: [%%(REMOTE_ADDR)s] %s' % (hostname,
+ settings.SYSLOG_TAG,
+ base_fmt),
},
'cef': {
'()': cef.SysLogFormatter,
@@ -95,4 +102,3 @@ def emit(self, record):
logger['propagate'] = False
dictconfig.dictConfig(cfg)
-

0 comments on commit cb6e708

Please sign in to comment.
Something went wrong with that request. Please try again.