You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ponymail.apache.org by se...@apache.org on 2020/03/18 14:19:31 UTC

[incubator-ponymail] branch master updated: Use a logger for more flexibility

This is an automated email from the ASF dual-hosted git repository.

sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ponymail.git


The following commit(s) were added to refs/heads/master by this push:
     new e6e6e2b  Use a logger for more flexibility
e6e6e2b is described below

commit e6e6e2b01f59659e44933ef79621a9c273ab688c
Author: Sebb <se...@apache.org>
AuthorDate: Wed Mar 18 14:19:03 2020 +0000

    Use a logger for more flexibility
---
 tools/import-mbox.py | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/tools/import-mbox.py b/tools/import-mbox.py
index 95ceb8c..86d91eb 100755
--- a/tools/import-mbox.py
+++ b/tools/import-mbox.py
@@ -289,7 +289,7 @@ class SlurpThread(Thread):
                     jas.append(json_source)
                     if args.verbose:
                         # TODO optionally show other fields (e.g. From_ line)
-                        print("MID:%(mid)s MSGID:%(message-id)s" % json)
+                        verbose_logger.info("MID:%(mid)s MSGID:%(message-id)s" , json)
                     if contents:
                         if not args.dry:
                             for key in contents:
@@ -434,6 +434,14 @@ print("Checking that the database index %s exists ... " % dbname)
 import logging
 logging.getLogger("elasticsearch").setLevel(logging.ERROR)
 
+verbose_logger = None
+if args.verbose:
+    verbose_logger = logging.getLogger("verbose")
+    verbose_logger.setLevel(logging.INFO)
+    # The default handler is set to WARN level
+    verbose_logger.addHandler(logging.StreamHandler(sys.stdout))
+    archiver.logger = verbose_logger
+
 if args.dry:
     print("Dry-run; continuing to check input data")
 else: