50
def configure_logging(config):
51
root_logger = logging.getLogger()
52
root_logger.setLevel(logging.INFO)
54
# glanceclient & keystoneclient use requests, which logs for every
55
# new HTTP connection, so let's make it a little less chatty:
56
logging.getLogger('requests').setLevel(logging.WARNING)
58
# If there is no ./logs directory, fallback to stderr.
59
log_path = os.path.abspath(
60
os.path.join(__file__, '../../logs/core-image-publisher.log'))
61
log_dir = os.path.dirname(log_path)
62
if os.path.exists(log_dir):
63
handler = logging.handlers.TimedRotatingFileHandler(
69
print("'logs' directory '{}' does not exist, using stderr "
70
"for app log.".format(log_dir))
71
handler = logging.StreamHandler()
75
'%(asctime)s %(name)s %(levelname)s: %(message)s'
78
root_logger.addHandler(handler)
79
if 'logstash' in config:
80
root_logger.addHandler(
81
logstash.LogstashHandler(
82
config['logstash']['host'],
83
int(config['logstash']['port']),
84
int(config['logstash']['version'])
90
49
config = read_config()
91
configure_logging(config)
50
log_path = os.path.abspath(
51
os.path.join(__file__, '../../logs/core-image-publisher.log')
53
configure_service_logging(
55
config['logstash'] if 'logstash' in config else None
92
57
connection = create_connection_from_config(config)