diff --git a/etc/grafyaml.conf b/etc/grafyaml.conf index 7dfa9d4..570824c 100644 --- a/etc/grafyaml.conf +++ b/etc/grafyaml.conf @@ -9,3 +9,89 @@ # API key for access grafana. (string value) #apikey = + +# +# From oslo.log +# + +# Print debugging output (set logging level to DEBUG instead of +# default WARNING level). (boolean value) +#debug = false + +# Print more verbose output (set logging level to INFO instead of +# default WARNING level). (boolean value) +#verbose = false + +# The name of a logging configuration file. This file is appended to +# any existing logging configuration files. For details about logging +# configuration files, see the Python logging module documentation. +# (string value) +# Deprecated group/name - [DEFAULT]/log_config +#log_config_append = + +# DEPRECATED. A logging.Formatter log message format string which may +# use any of the available logging.LogRecord attributes. This option +# is deprecated. Please use logging_context_format_string and +# logging_default_format_string instead. (string value) +#log_format = + +# Format string for %%(asctime)s in log records. Default: %(default)s +# . (string value) +#log_date_format = %Y-%m-%d %H:%M:%S + +# (Optional) Name of log file to output to. If no default is set, +# logging will go to stdout. (string value) +# Deprecated group/name - [DEFAULT]/logfile +#log_file = + +# (Optional) The base directory used for relative --log-file paths. +# (string value) +# Deprecated group/name - [DEFAULT]/logdir +#log_dir = + +# Use syslog for logging. Existing syslog format is DEPRECATED during +# I, and will change in J to honor RFC5424. (boolean value) +#use_syslog = false + +# (Optional) Enables or disables syslog rfc5424 format for logging. If +# enabled, prefixes the MSG part of the syslog message with APP-NAME +# (RFC5424). The format without the APP-NAME is deprecated in I, and +# will be removed in J. (boolean value) +#use_syslog_rfc_format = false + +# Syslog facility to receive log lines. (string value) +#syslog_log_facility = LOG_USER + +# Log output to standard error. (boolean value) +#use_stderr = true + +# Format string to use for log messages with context. (string value) +#logging_context_format_string = %(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s [%(request_id)s %(user_identity)s] %(instance)s%(message)s + +# Format string to use for log messages without context. (string +# value) +#logging_default_format_string = %(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s [-] %(instance)s%(message)s + +# Data to append to log format when level is DEBUG. (string value) +#logging_debug_format_suffix = %(funcName)s %(pathname)s:%(lineno)d + +# Prefix each line of exception output with this format. (string +# value) +#logging_exception_prefix = %(asctime)s.%(msecs)03d %(process)d TRACE %(name)s %(instance)s + +# List of logger=LEVEL pairs. (list value) +#default_log_levels = amqp=WARN,amqplib=WARN,boto=WARN,qpid=WARN,sqlalchemy=WARN,suds=INFO,oslo.messaging=INFO,iso8601=WARN,requests.packages.urllib3.connectionpool=WARN,urllib3.connectionpool=WARN,websocket=WARN,requests.packages.urllib3.util.retry=WARN,urllib3.util.retry=WARN,keystonemiddleware=WARN,routes.middleware=WARN,stevedore=WARN + +# Enables or disables publication of error events. (boolean value) +#publish_errors = false + +# Enables or disables fatal status of deprecations. (boolean value) +#fatal_deprecations = false + +# The format for an instance that is passed with the log message. +# (string value) +#instance_format = "[instance: %(uuid)s] " + +# The format for an instance UUID that is passed with the log message. +# (string value) +#instance_uuid_format = "[instance: %(uuid)s] " diff --git a/grafana_dashboards/cmd.py b/grafana_dashboards/cmd.py index e8ec1a7..b535e94 100644 --- a/grafana_dashboards/cmd.py +++ b/grafana_dashboards/cmd.py @@ -16,11 +16,13 @@ import inspect import sys from oslo_config import cfg +from oslo_log import log as logging from grafana_dashboards.builder import Builder from grafana_dashboards import config CONF = cfg.CONF +LOG = logging.getLogger(__name__) class Commands(object): @@ -51,6 +53,8 @@ def main(): CONF.register_cli_opt( cfg.SubCommandOpt('action', handler=add_command_parsers)) + logging.register_options(CONF) + logging.setup(CONF, 'grafana-dashboard') config.prepare_args(sys.argv) Commands().execute() diff --git a/requirements.txt b/requirements.txt index 57d527c..00cef7d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,5 +6,6 @@ pbr>=0.6,!=0.7,<1.0 Babel>=1.3 oslo.config>=1.11.0 +oslo.log>=1.0.0,<1.1.0 PyYAML>=3.1.0 voluptuous>=0.7 diff --git a/tox.ini b/tox.ini index 85ebe16..4783b13 100644 --- a/tox.ini +++ b/tox.ini @@ -14,7 +14,7 @@ commands = python setup.py test --slowest --testr-args='{posargs}' [testenv:genconfig] commands = - oslo-config-generator --namespace grafyaml --output-file etc/grafyaml.conf + oslo-config-generator --namespace grafyaml --namespace oslo.log --output-file etc/grafyaml.conf [testenv:pep8] commands = flake8