Repository: DataBiosphere/toil

Issue:
Lower log level of "Redirecting logging" message
Users get confused when they see the info-level logging redirection message in single-machine mode, but the file it names is gone (because it is just a temporary log buffer for Toil's log shipping system and not a real permanent log file).

We should hide the message from the users; really it is only needed if one is trying to debug the movement of log files.

┆Issue is synchronized with this [Jira Story](https://ucsc-cgl.atlassian.net/browse/TOIL-1368)
┆Issue Number: TOIL-1368



Discussion:

Resolving patch:
diff --git a/src/toil/cwl/__init__.py b/src/toil/cwl/__init__.py
--- a/src/toil/cwl/__init__.py
+++ b/src/toil/cwl/__init__.py
@@ -11,7 +11,7 @@
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
-import logging
+import sys
 from functools import lru_cache
 
 from pkg_resources import DistributionNotFound, get_distribution
@@ -28,31 +28,30 @@ class InvalidVersion(Exception):  # type: ignore
 
 from toil.version import cwltool_version
 
-logger = logging.getLogger(__name__)
-
 
 @lru_cache(maxsize=None)
 def check_cwltool_version() -> None:
     """
-    Check if the installed cwltool version matches Toil's expected version. A
-    warning is printed if the versions differ.
+    Check if the installed cwltool version matches Toil's expected version.
+
+    A warning is printed to standard error if the versions differ. We do not
+    assume that logging is set up already. Safe to call repeatedly; only one
+    warning will be printed.
     """
     try:
         installed_version = get_distribution("cwltool").version
 
         if installed_version != cwltool_version:
-            logger.warning(
-                f"You are using cwltool version {installed_version}, which might not be compatible with "
-                f"version {cwltool_version} used by Toil. You should consider running 'pip install cwltool=="
-                f"{cwltool_version}' to match Toil's cwltool version."
+            sys.stderr.write(
+                f"WARNING: You are using cwltool version {installed_version}, which is "
+                f"not the version Toil is tested against. To install the correct cwltool "
+                f"for Toil, do:\n\n\tpip install cwltool=={cwltool_version}\n\n"
             )
     except DistributionNotFound:
-        logger.debug("cwltool is not installed.")
+        # cwltool is not installed
+        pass
     except InvalidVersion as e:
-        logger.warning(
-            f"Could not determine the installed version of cwltool because a package "
-            f"with an unacceptable version is installed: {e}"
+        sys.stderr.write(
+            f"WARNING: Could not determine the installed version of cwltool because a package "
+            f"with an unacceptable version is installed: {e}\n"
         )
-
-
-check_cwltool_version()
diff --git a/src/toil/cwl/cwltoil.py b/src/toil/cwl/cwltoil.py
--- a/src/toil/cwl/cwltoil.py
+++ b/src/toil/cwl/cwltoil.py
@@ -104,6 +104,8 @@
 
 from toil.batchSystems.registry import DEFAULT_BATCH_SYSTEM
 from toil.common import Config, Toil, addOptions
+from toil.cwl import check_cwltool_version
+check_cwltool_version()
 from toil.cwl.utils import (
     CWL_UNSUPPORTED_REQUIREMENT_EXCEPTION,
     CWL_UNSUPPORTED_REQUIREMENT_EXIT_CODE,
diff --git a/src/toil/worker.py b/src/toil/worker.py
--- a/src/toil/worker.py
+++ b/src/toil/worker.py
@@ -250,8 +250,8 @@ def workerScript(jobStore: AbstractJobStore, config: Config, jobName: str, jobSt
 
     if redirectOutputToLogFile:
         # Announce that we are redirecting logging, and where it will now go.
-        # This is important if we are trying to manually trace a faulty worker invocation.
-        logger.info("Redirecting logging to %s", tempWorkerLogPath)
+        # This is only important if we are trying to manually trace a faulty worker invocation.
+        logger.debug("Redirecting logging to %s", tempWorkerLogPath)
         sys.stdout.flush()
         sys.stderr.flush()
 


Test patch: