changeset 378:0860204227de

Fix logging issue
author Amine Sehili <amine.sehili@gmail.com>
date Wed, 17 Feb 2021 22:44:23 +0100
parents c6308873f239
children df2a320e10d5
files auditok/cmdline.py auditok/cmdline_util.py auditok/workers.py
diffstat 3 files changed, 11 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/auditok/cmdline.py	Wed Feb 17 21:18:05 2021 +0100
+++ b/auditok/cmdline.py	Wed Feb 17 22:44:23 2021 +0100
@@ -266,16 +266,17 @@
 
         group = parser.add_argument_group(
             "Do something with audio events",
-            "Use these options to print, play or plot detections.",
+            "Use these options to print, play back or plot detections.",
         )
         group.add_argument(
             "-C",
             "--command",
             dest="command",
             type=str,
-            help="Command to call when an audio detection occurs. Use $ to "
-            "represent the file name to use with the command (e.g. -C "
-            "'du -h $')",
+            help="Command to call when an audio detection occurs. Use '{file}' "
+            "as a placeholder for the temporary wav file that will contain "
+            "event's data (e.g., \"-C 'du -h {file}'\" to print out file size "
+            " or \"-C 'play -q {file}'\" to play audio with sox)",
             metavar="STRING",
         )
         group.add_argument(
@@ -347,7 +348,8 @@
             type=str,
             default="%Y/%m/%d %H:%M:%S",
             help="Format used to print {timestamp}. Should be a format "
-            "accepted by datetime Default %%Y/%%m/%%d %%H:%%M:%%S",
+            "accepted by 'datetime' standard module. Default: "
+            "'%%Y/%%m/%%d %%H:%%M:%%S'",
         )
         parser.add_argument(
             "-q",
--- a/auditok/cmdline_util.py	Wed Feb 17 21:18:05 2021 +0100
+++ b/auditok/cmdline_util.py	Wed Feb 17 22:44:23 2021 +0100
@@ -64,16 +64,17 @@
     if not stderr and file is None:
         return None
     logger = logging.getLogger(name)
+    logger.setLevel(logging.INFO)
     if stderr:
         handler = logging.StreamHandler(sys.stderr)
-        handler.setLevel(logging.DEBUG)
+        handler.setLevel(logging.INFO)
         logger.addHandler(handler)
 
     if file is not None:
         handler = logging.FileHandler(file, "w")
         fmt = logging.Formatter("[%(asctime)s] | %(message)s")
         handler.setFormatter(fmt)
-        handler.setLevel(logging.DEBUG)
+        handler.setLevel(logging.INFO)
         logger.addHandler(handler)
     return logger
 
--- a/auditok/workers.py	Wed Feb 17 21:18:05 2021 +0100
+++ b/auditok/workers.py	Wed Feb 17 22:44:23 2021 +0100
@@ -390,7 +390,7 @@
     def _process_message(self, message):
         _id, audio_region = message
         with NamedTemporaryFile(delete=False) as file:
-            filename = audio_region.save(file.name, "raw")
+            filename = audio_region.save(file.name, audio_format="wav")
             command = self._command.format(file=filename)
             os.system(command)
             if self._logger is not None: