Merge "add UDP protocol support for logger"
This commit is contained in:
commit
0ab4f2ab4a
1
AUTHORS
1
AUTHORS
@ -79,3 +79,4 @@ Ye Jia Xu (xyj.asmy@gmail.com)
|
|||||||
Pete Zaitcev (zaitcev@kotori.zaitcev.us)
|
Pete Zaitcev (zaitcev@kotori.zaitcev.us)
|
||||||
Josh Kearney (josh@jk0.org)
|
Josh Kearney (josh@jk0.org)
|
||||||
Vincent Untz (vuntz@suse.com)
|
Vincent Untz (vuntz@suse.com)
|
||||||
|
Tsuyuzaki Kota (tsuyuzaki.kota@lab.ntt.co.jp)
|
||||||
|
@ -94,7 +94,8 @@ class ProxyLoggingMiddleware(object):
|
|||||||
self.app = app
|
self.app = app
|
||||||
self.log_hdrs = conf.get('log_headers', 'no').lower() in TRUE_VALUES
|
self.log_hdrs = conf.get('log_headers', 'no').lower() in TRUE_VALUES
|
||||||
access_log_conf = {}
|
access_log_conf = {}
|
||||||
for key in ('log_facility', 'log_name', 'log_level'):
|
for key in ('log_facility', 'log_name', 'log_level', 'log_udp_host',
|
||||||
|
'log_udp_port'):
|
||||||
value = conf.get('access_' + key, conf.get(key, None))
|
value = conf.get('access_' + key, conf.get(key, None))
|
||||||
if value:
|
if value:
|
||||||
access_log_conf[key] = value
|
access_log_conf[key] = value
|
||||||
|
@ -533,6 +533,8 @@ def get_logger(conf, name=None, log_to_console=False, log_route=None,
|
|||||||
log_facility = LOG_LOCAL0
|
log_facility = LOG_LOCAL0
|
||||||
log_level = INFO
|
log_level = INFO
|
||||||
log_name = swift
|
log_name = swift
|
||||||
|
log_udp_host = (disabled)
|
||||||
|
log_udp_port = logging.handlers.SYSLOG_UDP_PORT
|
||||||
log_statsd_host = (disabled)
|
log_statsd_host = (disabled)
|
||||||
log_statsd_port = 8125
|
log_statsd_port = 8125
|
||||||
log_statsd_default_sample_rate = 1
|
log_statsd_default_sample_rate = 1
|
||||||
@ -564,13 +566,19 @@ def get_logger(conf, name=None, log_to_console=False, log_route=None,
|
|||||||
# facility for this logger will be set by last call wins
|
# facility for this logger will be set by last call wins
|
||||||
facility = getattr(SysLogHandler, conf.get('log_facility', 'LOG_LOCAL0'),
|
facility = getattr(SysLogHandler, conf.get('log_facility', 'LOG_LOCAL0'),
|
||||||
SysLogHandler.LOG_LOCAL0)
|
SysLogHandler.LOG_LOCAL0)
|
||||||
log_address = conf.get('log_address', '/dev/log')
|
udp_host = conf.get('log_udp_host')
|
||||||
try:
|
if udp_host:
|
||||||
handler = SysLogHandler(address=log_address, facility=facility)
|
udp_port = conf.get('log_udp_port', logging.handlers.SYSLOG_UDP_PORT)
|
||||||
except socket.error, e:
|
handler = SysLogHandler(address=(udp_host, udp_port),
|
||||||
if e.errno != errno.ENOTSOCK: # Socket operation on non-socket
|
facility=facility)
|
||||||
raise e
|
else:
|
||||||
handler = SysLogHandler(facility=facility)
|
log_address = conf.get('log_address', '/dev/log')
|
||||||
|
try:
|
||||||
|
handler = SysLogHandler(address=log_address, facility=facility)
|
||||||
|
except socket.error, e:
|
||||||
|
if e.errno != errno.ENOTSOCK: # Socket operation on non-socket
|
||||||
|
raise e
|
||||||
|
handler = SysLogHandler(facility=facility)
|
||||||
handler.setFormatter(formatter)
|
handler.setFormatter(formatter)
|
||||||
logger.addHandler(handler)
|
logger.addHandler(handler)
|
||||||
get_logger.handler4logger[logger] = handler
|
get_logger.handler4logger[logger] = handler
|
||||||
|
@ -1870,7 +1870,8 @@ class BaseApplication(object):
|
|||||||
if logger is None:
|
if logger is None:
|
||||||
self.logger = get_logger(conf, log_route='proxy-server')
|
self.logger = get_logger(conf, log_route='proxy-server')
|
||||||
access_log_conf = {}
|
access_log_conf = {}
|
||||||
for key in ('log_facility', 'log_name', 'log_level'):
|
for key in ('log_facility', 'log_name', 'log_level',
|
||||||
|
'log_udp_host', 'log_udp_port'):
|
||||||
value = conf.get('access_' + key, conf.get(key, None))
|
value = conf.get('access_' + key, conf.get(key, None))
|
||||||
if value:
|
if value:
|
||||||
access_log_conf[key] = value
|
access_log_conf[key] = value
|
||||||
|
Loading…
Reference in New Issue
Block a user