Permalink
Browse files

Merge pull request #51 from oremj/fix_log_source

Add source to log lines.
  • Loading branch information...
2 parents faca9a7 + cb6e708 commit 1d22d9058351177e6d7da13f28517221e6e95571 @kumar303 kumar303 committed May 14, 2013
Showing with 9 additions and 3 deletions.
  1. +9 −3 funfactory/log_settings.py
View
@@ -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 1d22d90

Please sign in to comment.