Repository: datalad/datalad

Issue:
[INFO] Clear progress bars [INFO] Refresh progress bars on 0.13.0rc2
#### What is the problem?
Just a quick report. I run the following code to search for missing local annex files:
```bash
echo "Searching for missing files" ; \
datalad -f json status --recursive --annex all | \
jq '. | select(.has_content == false).path'
```
Works as before on 0.12.7, but shows the following messages in 0.13.0.rc2
```bash
[INFO] Clear progress bars
[INFO] Refresh progress bars
[INFO] Clear progress bars
[INFO] Refresh progress bars
[INFO] Clear progress bars
[INFO] Refresh progress bars
[INFO] Clear progress bars
```
Not sure if this is just temporary code you put to debug stuff, but just wanted to report it for now.

#### What steps will reproduce the problem?
See above.

#### What version of DataLad are you using (run `datalad --version`)? On what operating system (consider running `datalad wtf`)?
See above.

#### Is there anything else that would be useful to know in this context?
No

#### Have you had any success using DataLad before? (to assess your expertise/prior luck.  We would welcome your testimonial additions to https://github.com/datalad/datalad/wiki/Testimonials as well)
Yes

Discussion:

Patch:
diff --git a/datalad/ui/dialog.py b/datalad/ui/dialog.py
index cf86ecdba..7bed97683 100644
--- a/datalad/ui/dialog.py
+++ b/datalad/ui/dialog.py
@@ -72,11 +72,13 @@ class ConsoleLog(object):
 
     def message(self, msg, cr='\n'):
         from datalad.log import log_progress
-        log_progress(lgr.info, None, 'Clear progress bars', maint='clear')
+        log_progress(lgr.info, None, 'Clear progress bars', maint='clear',
+                     noninteractive_level=5)
         self.out.write(msg)
         if cr:
             self.out.write(cr)
-        log_progress(lgr.info, None, 'Refresh progress bars', maint='refresh')
+        log_progress(lgr.info, None, 'Refresh progress bars', maint='refresh',
+                     noninteractive_level=5)
 
     def error(self, error):
         self.out.write("ERROR: %s\n" % error)


Test patch:
diff --git a/datalad/ui/tests/test_dialog.py b/datalad/ui/tests/test_dialog.py
index c7b5e9ea1..f104af9c2 100644
--- a/datalad/ui/tests/test_dialog.py
+++ b/datalad/ui/tests/test_dialog.py
@@ -17,6 +17,8 @@ from unittest.mock import (
     call,
     patch,
 )
+
+from datalad.utils import swallow_logs
 from ...tests.utils import (
     assert_in,
     assert_not_in,
@@ -27,6 +29,7 @@ from ...tests.utils import (
     ok_startswith,
 )
 from ..dialog import (
+    ConsoleLog,
     DialogUI,
     IPythonUI,
 )
@@ -187,4 +190,23 @@ def test_silent_question():
     # additional kwargs, no title, choices
     with assert_raises(RuntimeError) as cme:
         ui.question("q", choices=['secret1'])
-    assert_in('secret1', str(cme.exception))
\ No newline at end of file
+    assert_in('secret1', str(cme.exception))
+
+
+@patch("datalad.log.is_interactive", lambda: False)
+def test_message_pbar_state_logging_is_demoted():
+    from datalad.log import LoggerHelper
+
+    name = "dl-test"
+    lgr = LoggerHelper(name).get_initialized_logger()
+    ui = ConsoleLog()
+
+    with patch("datalad.ui.dialog.lgr", lgr):
+        with swallow_logs(name=name, new_level=20) as cml:
+            ui.message("testing 0")
+            assert_not_in("Clear progress bars", cml.out)
+            assert_not_in("Refresh progress bars", cml.out)
+        with swallow_logs(name=name, new_level=5) as cml:
+            ui.message("testing 1")
+            assert_in("Clear progress bars", cml.out)
+            assert_in("Refresh progress bars", cml.out)