Skip to content

Instantly share code, notes, and snippets.

@lacoski
Forked from dims/app.py
Created December 29, 2018 01:32
Show Gist options
  • Save lacoski/0d54fdd55ac629a7f151c6d9af224fee to your computer and use it in GitHub Desktop.
Save lacoski/0d54fdd55ac629a7f151c6d9af224fee to your computer and use it in GitHub Desktop.
oslo.config + oslo.log sample
import sys
from oslo.config import cfg
from oslo_log import log as oslo_logging
CONF = cfg.CONF
CONF.register_opt(cfg.StrOpt('NODE_NAME'), cfg.OptGroup('HA'))
def main():
oslo_logging.register_options(CONF)
CONF(sys.argv[1:], default_config_files=['app.conf'])
oslo_logging.setup(CONF, 'xyz')
LOG = oslo_logging.getLogger('')
try:
raise Exception('hello')
except:
LOG.error('got exception')
if __name__ == '__main__':
main()
#/etc/my.conf
[DEFAULT]
###########
# Logging #
###########
# syslog server configuration (default port(UDP): 514)
# NOTE: Following logging configuration can be left as is for logs to come on UI
syslog_host=127.0.0.1
syslog_port=514
# log facility
log_facility=LOG_LOCAL3
[HA]
NODE_NAME=NODE1
DIR_STR=/opt
[OPENSTACK]
HA_VIRTUAL_IP=192.168.0.26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment