Fix logging in cfn-init and cfn-signal

logging.getLogger() was called with a wrong name in the cfn scripts. As
a result, the cfn_helper module logged everything to stderr.

Change-Id: I3447291b202887aa09b0f0cb01764708683e7821
Closes-Bug: #1269355
This commit is contained in:
Simon Pasquier 2014-01-15 12:24:09 +01:00
parent 1d0bf6b18f
commit 3eef3a451c
3 changed files with 12 additions and 19 deletions

View File

@ -45,17 +45,12 @@ args = parser.parse_args()
# Setup logging
log_format = '%(levelname)s [%(asctime)s] %(message)s'
log_file_name = "/var/log/cfn-hup.log"
log_level = logging.INFO
if args.verbose:
log_level = logging.DEBUG
logging.basicConfig(filename=log_file_name,
format=log_format,
level=logging.DEBUG)
if args.verbose:
logging.basicConfig(filename=log_file_name,
format=log_format,
level=logging.DEBUG)
else:
logging.basicConfig(filename=log_file_name,
format=log_format,
level=logging.INFO)
level=log_level)
LOG = logging.getLogger('cfntools')

View File

@ -50,13 +50,12 @@ parser.add_argument('-c', '--configsets',
args = parser.parse_args()
log_format = '%(levelname)s [%(asctime)s] %(message)s'
logging.basicConfig(format=log_format, level=logging.DEBUG)
log_file_name = "/var/log/cfn-init.log"
logging.basicConfig(filename=log_file_name,
format=log_format,
level=logging.DEBUG)
LOG = logging.getLogger('cfntools')
log_file_name = "/var/log/cfn-init.log"
file_handler = logging.FileHandler(log_file_name)
file_handler.setFormatter(logging.Formatter(log_format))
LOG.addHandler(file_handler)
metadata = cfn_helper.Metadata(args.stack_name,
args.logical_resource_id,

View File

@ -60,13 +60,12 @@ parser.add_argument('url',
args = parser.parse_args()
log_format = '%(levelname)s [%(asctime)s] %(message)s'
logging.basicConfig(format=log_format, level=logging.DEBUG)
log_file_name = "/var/log/cfn-signal.log"
logging.basicConfig(filename=log_file_name,
format=log_format,
level=logging.DEBUG)
LOG = logging.getLogger('cfntools')
log_file_name = "/var/log/cfn-signal.log"
file_handler = logging.FileHandler(log_file_name)
file_handler.setFormatter(logging.Formatter(log_format))
LOG.addHandler(file_handler)
LOG.debug('cfn-signal called %s ' % (str(args)))
if args.exit: