Merge pull request #3144 from TheNavigat/test-logging

Adding sensible UI logging for typical user
This commit is contained in:
Brad Warren
2016-06-21 14:25:36 -07:00
committed by GitHub
5 changed files with 11 additions and 10 deletions
+1 -1
View File
@@ -282,7 +282,7 @@ class Client(object):
"by your operating system package manager") "by your operating system package manager")
if self.config.dry_run: if self.config.dry_run:
logger.info("Dry run: Skipping creating new lineage for %s", logger.debug("Dry run: Skipping creating new lineage for %s",
domains[0]) domains[0])
return None return None
else: else:
+1 -1
View File
@@ -18,7 +18,7 @@ CLI_DEFAULTS = dict(
os.path.join(os.environ.get("XDG_CONFIG_HOME", "~/.config"), os.path.join(os.environ.get("XDG_CONFIG_HOME", "~/.config"),
"letsencrypt", "cli.ini"), "letsencrypt", "cli.ini"),
], ],
verbose_count=-(logging.WARNING / 10), verbose_count=-(logging.INFO / 10),
server="https://acme-v01.api.letsencrypt.org/directory", server="https://acme-v01.api.letsencrypt.org/directory",
rsa_key_size=2048, rsa_key_size=2048,
rollback_checkpoints=1, rollback_checkpoints=1,
+5 -4
View File
@@ -527,7 +527,7 @@ def _csr_obtain_cert(config, le_client):
csr, typ = config.actual_csr csr, typ = config.actual_csr
certr, chain = le_client.obtain_certificate_from_csr(config.domains, csr, typ) certr, chain = le_client.obtain_certificate_from_csr(config.domains, csr, typ)
if config.dry_run: if config.dry_run:
logger.info( logger.debug(
"Dry run: skipping saving certificate to %s", config.cert_path) "Dry run: skipping saving certificate to %s", config.cert_path)
else: else:
cert_path, _, cert_fullchain = le_client.save_certificate( cert_path, _, cert_fullchain = le_client.save_certificate(
@@ -625,11 +625,12 @@ def _cli_log_handler(config, level, fmt):
def setup_logging(config, cli_handler_factory, logfile): def setup_logging(config, cli_handler_factory, logfile):
"""Setup logging.""" """Setup logging."""
fmt = "%(asctime)s:%(levelname)s:%(name)s:%(message)s" file_fmt = "%(asctime)s:%(levelname)s:%(name)s:%(message)s"
cli_fmt = "%(message)s"
level = -config.verbose_count * 10 level = -config.verbose_count * 10
file_handler, log_file_path = setup_log_file_handler( file_handler, log_file_path = setup_log_file_handler(
config, logfile=logfile, fmt=fmt) config, logfile=logfile, fmt=file_fmt)
cli_handler = cli_handler_factory(config, level, fmt) cli_handler = cli_handler_factory(config, level, cli_fmt)
# TODO: use fileConfig? # TODO: use fileConfig?
+3 -3
View File
@@ -108,7 +108,7 @@ def _restore_webroot_config(config, renewalparams):
if not cli.set_by_cli("webroot_map"): if not cli.set_by_cli("webroot_map"):
config.namespace.webroot_map = renewalparams["webroot_map"] config.namespace.webroot_map = renewalparams["webroot_map"]
elif "webroot_path" in renewalparams: elif "webroot_path" in renewalparams:
logger.info("Ancient renewal conf file without webroot-map, restoring webroot-path") logger.debug("Ancient renewal conf file without webroot-map, restoring webroot-path")
wp = renewalparams["webroot_path"] wp = renewalparams["webroot_path"]
if isinstance(wp, str): # prior to 0.1.0, webroot_path was a string if isinstance(wp, str): # prior to 0.1.0, webroot_path was a string
wp = [wp] wp = [wp]
@@ -194,7 +194,7 @@ def _restore_required_config_elements(config, renewalparams):
def should_renew(config, lineage): def should_renew(config, lineage):
"Return true if any of the circumstances for automatic renewal apply." "Return true if any of the circumstances for automatic renewal apply."
if config.renew_by_default: if config.renew_by_default:
logger.info("Auto-renewal forced with --force-renewal...") logger.debug("Auto-renewal forced with --force-renewal...")
return True return True
if lineage.should_autorenew(interactive=True): if lineage.should_autorenew(interactive=True):
logger.info("Cert is due for renewal, auto-renewing...") logger.info("Cert is due for renewal, auto-renewing...")
@@ -236,7 +236,7 @@ def renew_cert(config, domains, le_client, lineage):
_avoid_invalidating_lineage(config, lineage, original_server) _avoid_invalidating_lineage(config, lineage, original_server)
new_certr, new_chain, new_key, _ = le_client.obtain_certificate(domains) new_certr, new_chain, new_key, _ = le_client.obtain_certificate(domains)
if config.dry_run: if config.dry_run:
logger.info("Dry run: skipping updating lineage at %s", logger.debug("Dry run: skipping updating lineage at %s",
os.path.dirname(lineage.cert)) os.path.dirname(lineage.cert))
else: else:
prior_version = lineage.latest_common_version() prior_version = lineage.latest_common_version()
+1 -1
View File
@@ -58,7 +58,7 @@ class Reporter(object):
""" """
assert self.HIGH_PRIORITY <= priority <= self.LOW_PRIORITY assert self.HIGH_PRIORITY <= priority <= self.LOW_PRIORITY
self.messages.put(self._msg_type(priority, msg, on_crash)) self.messages.put(self._msg_type(priority, msg, on_crash))
logger.info("Reporting to user: %s", msg) logger.debug("Reporting to user: %s", msg)
def atexit_print_messages(self, pid=None): def atexit_print_messages(self, pid=None):
"""Function to be registered with atexit to print messages. """Function to be registered with atexit to print messages.