Repository: Qiskit/qiskit

Issue:
Add quiet= and to_err= to job monitor to suppress or redirect status messages. 
<!-- ⚠️ If you do not respect this template, your issue will be closed -->
<!-- ⚠️ Make sure to browse the opened and closed issues to confirm this idea does not exist. -->

### Add quiet= and to_err= to job monitor to suppress or redirect status messages. 

If one captures output from a script, `qiskit.tools.monitor.job_monitor` (and its factor, `_text_checker`) spew extraneous info. Suppress with `quiet=True` or redirect to stderr with `to_err=True`.



Discussion:

Resolving patch:
diff --git a/qiskit/tools/monitor/job_monitor.py b/qiskit/tools/monitor/job_monitor.py
--- a/qiskit/tools/monitor/job_monitor.py
+++ b/qiskit/tools/monitor/job_monitor.py
@@ -19,20 +19,25 @@
     from IPython.display import display    # pylint: disable=import-error
 
 
-def _text_checker(job, interval, _interval_set=False):
+def _text_checker(job, interval, _interval_set=False, quiet=False, output=sys.stdout):
     """A text-based job status checker
 
     Args:
         job (BaseJob): The job to check.
         interval (int): The interval at which to check.
         _interval_set (bool): Was interval time set by user?
+        quiet (bool): If True, do not print status messages.
+        output (file): The file like object to write status messages to.
+        By default this is sys.stdout.
+
     """
     status = job.status()
     msg = status.value
     prev_msg = msg
     msg_len = len(msg)
 
-    print('\r%s: %s' % ('Job Status', msg), end='')
+    if not quiet:
+        print('\r%s: %s' % ('Job Status', msg), end='', file=output)
     while status.name not in ['DONE', 'CANCELLED', 'ERROR']:
         time.sleep(interval)
         status = job.status()
@@ -52,19 +57,23 @@ def _text_checker(job, interval, _interval_set=False):
         elif len(msg) > msg_len:
             msg_len = len(msg)
 
-        if msg != prev_msg:
-            print('\r%s: %s' % ('Job Status', msg), end='')
+        if msg != prev_msg and not quiet:
+            print('\r%s: %s' % ('Job Status', msg), end='', file=output)
             prev_msg = msg
-    print('')
+    if not quiet:
+        print('', file=output)
 
 
-def job_monitor(job, interval=None, monitor_async=False):
+def job_monitor(job, interval=None, monitor_async=False, quiet=False, output=sys.stdout):
     """Monitor the status of a IBMQJob instance.
 
     Args:
         job (BaseJob): Job to monitor.
         interval (int): Time interval between status queries.
         monitor_async (bool): Monitor asyncronously (in Jupyter only).
+        quiet (bool): If True, do not print status messages.
+        output (file): The file like object to write status messages to.
+        By default this is sys.stdout.
 
     Raises:
         QiskitError: When trying to run async outside of Jupyter
@@ -85,7 +94,8 @@ def job_monitor(job, interval=None, monitor_async=False):
             from qiskit.tools.jupyter.jupyter_magics import _html_checker  # pylint: disable=C0412
 
             style = "font-size:16px;"
-            header = "<p style='{style}'>Job Status: %s </p>".format(style=style)
+            header = "<p style='{style}'>Job Status: %s </p>".format(
+                style=style)
             status = widgets.HTML(value=header % job.status().value)
             display(status)
 
@@ -93,9 +103,11 @@ def job_monitor(job, interval=None, monitor_async=False):
                                                                   status, header))
             thread.start()
         else:
-            _text_checker(job, interval, _interval_set)
+            _text_checker(job, interval, _interval_set,
+                          quiet=quiet, output=output)
 
     else:
         if monitor_async:
-            raise QiskitError('monitor_async only available in Jupyter notebooks.')
-        _text_checker(job, interval, _interval_set)
+            raise QiskitError(
+                'monitor_async only available in Jupyter notebooks.')
+        _text_checker(job, interval, _interval_set, quiet=quiet, output=output)


Test patch: