Improve logging in octavia.cmd

We should delegate (when possible) formatting to the logger in order to
perform formatting only when needed, by using:

 LOG.<level>(message, data)

instead of:

 LOG.<level>(message % data)

and

 try:
   ...
 except ...:
   LOG.exception("lorem ipsum")

instead of:

 try:
   ...
 except ... as e:
   LOG.error("lorem ipsum: %s:", e)

Change-Id: Ibbbd4c9bf20ffc4387bca7f04e51a9e8759ac882
This commit is contained in:
Cedric Brandily 2015-10-02 10:13:41 +00:00
parent d41599e5a5
commit 6f16648bcf
2 changed files with 5 additions and 5 deletions

View File

@ -33,7 +33,7 @@ def main():
app = api_app.setup_app()
host, port = cfg.CONF.bind_host, cfg.CONF.bind_port
LOG.info(_LI("Starting API server on %(host)s:%(port)s") %
LOG.info(_LI("Starting API server on %(host)s:%(port)s"),
{"host": host, "port": port})
srv = simple_server.make_server(host, port, app)

View File

@ -38,7 +38,7 @@ def spare_amphora_check():
# Read the interval from CONF
interval = CONF.house_keeping.spare_check_interval
LOG.info(_LI("Spare check interval is set to %d sec") % interval)
LOG.info(_LI("Spare check interval is set to %d sec"), interval)
spare_amp = house_keeping.SpareAmphora()
while spare_amp_thread_event.is_set():
@ -51,8 +51,8 @@ def db_cleanup():
"""Perform db cleanup for old amphora."""
# Read the interval from CONF
interval = CONF.house_keeping.cleanup_interval
LOG.info(_LI("DB cleanup interval is set to %d sec") % interval)
LOG.info(_LI('Amphora expiry age is %s seconds') %
LOG.info(_LI("DB cleanup interval is set to %d sec"), interval)
LOG.info(_LI('Amphora expiry age is %s seconds'),
CONF.house_keeping.amphora_expiry_age)
db_cleanup = house_keeping.DatabaseCleanup()
@ -66,7 +66,7 @@ def main():
service.prepare_service(sys.argv)
timestamp = str(datetime.datetime.utcnow())
LOG.info(_LI("Starting house keeping at %s") % timestamp)
LOG.info(_LI("Starting house keeping at %s"), timestamp)
# Thread to perform spare amphora check
spare_amp_thread = threading.Thread(target=spare_amphora_check)