Skip to content

Commit

Permalink
Merge "Add ability to specify syslog facility"
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenkins authored and openstack-gerrit committed Jan 3, 2012
2 parents 2532c88 + add97aa commit 98b19af
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 8 deletions.
12 changes: 9 additions & 3 deletions etc/glance-api.conf
Expand Up @@ -20,12 +20,18 @@ bind_port = 9292
# file for both the API and registry servers!
log_file = /var/log/glance/api.log

# Send logs to syslog (/dev/log) instead of to file specified by `log_file`
use_syslog = False

# Backlog requests when creating socket
backlog = 4096

# ================= Syslog Options ============================

# Send logs to syslog (/dev/log) instead of to file specified
# by `log_file`
use_syslog = False

# Facility to use. If unset defaults to LOG_USER.
# syslog_log_facility = LOG_LOCAL0

# ================= SSL Options ===============================

# Certificate file to use when starting API server securely
Expand Down
12 changes: 9 additions & 3 deletions etc/glance-registry.conf
Expand Up @@ -15,9 +15,6 @@ bind_port = 9191
# file for both the API and registry servers!
log_file = /var/log/glance/registry.log

# Send logs to syslog (/dev/log) instead of to file specified by `log_file`
use_syslog = False

# Backlog requests when creating socket
backlog = 4096

Expand All @@ -43,6 +40,15 @@ api_limit_max = 1000
# default to `limit_param_default`
limit_param_default = 25

# ================= Syslog Options ============================

# Send logs to syslog (/dev/log) instead of to file specified
# by `log_file`
use_syslog = False

# Facility to use. If unset defaults to LOG_USER.
# syslog_log_facility = LOG_LOCAL1

# ================= SSL Options ===============================

# Certificate file to use when starting registry server securely
Expand Down
3 changes: 3 additions & 0 deletions glance/common/cfg.py
Expand Up @@ -1118,6 +1118,9 @@ class CommonConfigOpts(ConfigOpts):
BoolOpt('use-syslog',
default=False,
help='Use syslog for logging.'),
StrOpt('syslog-log-facility',
default='LOG_USER',
help='syslog facility to receive log lines')
]

def __init__(self, **kwargs):
Expand Down
10 changes: 8 additions & 2 deletions glance/common/config.py
Expand Up @@ -28,7 +28,6 @@

from glance import version
from glance.common import cfg
from glance.common import utils
from glance.common import wsgi


Expand Down Expand Up @@ -77,7 +76,14 @@ def setup_logging(conf):
formatter = logging.Formatter(conf.log_format, conf.log_date_format)

if conf.use_syslog:
handler = logging.handlers.SysLogHandler(address='/dev/log')
try:
facility = getattr(logging.handlers.SysLogHandler,
conf.syslog_log_facility)
except AttributeError:
raise ValueError(_("Invalid syslog facility"))

handler = logging.handlers.SysLogHandler(address='/dev/log',
facility=facility)
elif conf.log_file:
logfile = conf.log_file
if conf.log_dir:
Expand Down

0 comments on commit 98b19af

Please sign in to comment.