Repository: modin-project/modin
Pull request: FIX-#4518: Fix Modin Logging to report specific Modin warnings/errors
Signed-off-by: Naren Krishna <naren@ponder.io>

<!--
Thank you for your contribution!
Please review the contributing docs: https://modin.readthedocs.io/en/latest/development/contributing.html
if you have questions about contributing.
-->

## What do these changes do?

Modin Logging currently reports several lines like:

> 88001, 4538414592, 2022-05-26,16:44:07.377470, START::MODIN-ERROR::ErrorMessage.catch_bugs_and_request_email
> 88001, 4538414592, 2022-05-26,16:44:07.377538, STOP::MODIN-ERROR::ErrorMessage.catch_bugs_and_request_email

We want to only report the specific errors and not the API calls to these functions that do not raise the actual exceptions.


- [x] commit message follows format outlined [here](https://modin.readthedocs.io/en/latest/development/contributing.html#commit-message-formatting)
- [x] passes `flake8 modin/ asv_bench/benchmarks scripts/doc_checker.py`
- [x] passes `black --check modin/ asv_bench/benchmarks scripts/doc_checker.py`
- [x] signed commit with `git commit -s` <!-- you can amend your commit with a signature via `git commit -amend -s` -->
- [x] Resolves #4518 ? <!-- issue must be created for each patch -->
- [x] tests added and passing
- [x] module layout described at `docs/development/architecture.rst` is up-to-date <!-- if you have added, renamed or removed files or directories please update the documentation accordingly -->
- [x] added (Issue Number: PR title (PR Number)) and github username to release notes for next major release <!-- e.g. DOCS-#4077: Add release notes template to docs folder (#4078) -->


Problem statement:
Fix Modin Logging to report specific errors instead of error API calls
### Describe the problem

Modin Logging reports several lines like:

> 88001, 4538414592, 2022-05-26,16:44:07.377470, START::MODIN-ERROR::ErrorMessage.catch_bugs_and_request_email
> 88001, 4538414592, 2022-05-26,16:44:07.377538, STOP::MODIN-ERROR::ErrorMessage.catch_bugs_and_request_email 

We want to only report the specific errors and not the API calls to these functions that do not raise the actual exceptions.

### Source code / logs
<!-- Include any logs or source code that would be helpful to diagnose the problem. If including tracebacks, please include the full traceback. Large logs and files should be attached. Try to provide a reproducible test case that is the bare minimum necessary to generate the problem. -->

Hints from issue discussion:

Commit message: remove single warning log line

Signed-off-by: Naren Krishna <naren@ponder.io>

Patch to review:
diff --git a/docs/release_notes/release_notes-0.15.0.rst b/docs/release_notes/release_notes-0.15.0.rst
index b24efe1df39..c66b661150a 100644
--- a/docs/release_notes/release_notes-0.15.0.rst
+++ b/docs/release_notes/release_notes-0.15.0.rst
@@ -22,6 +22,7 @@ Key Features and Updates
   * FIX-#4461: Fix S3 CSV data path (#4462)
   * FIX-#4467: `drop_duplicates` no longer removes items based on index values (#4468)
   * FIX-#4449: Drain the call queue before waiting on result in benchmark mode (#4472)
+  * FIX-#4518: Fix Modin Logging to report specific Modin warnings/errors (#4519)
   * FIX-#4481: Allow clipping with a Modin Series of bounds (#4486)  
   * FIX-#4504: Support na_action in applymap (#4505)
 * Performance enhancements
diff --git a/modin/error_message.py b/modin/error_message.py
index db9a85c596a..f24649b93ff 100644
--- a/modin/error_message.py
+++ b/modin/error_message.py
@@ -12,7 +12,7 @@
 # governing permissions and limitations under the License.
 
 import warnings
-from modin.logging import logger_decorator
+from modin.logging import get_logger
 
 
 class ErrorMessage(object):
@@ -21,10 +21,10 @@ class ErrorMessage(object):
     printed_warnings = set()
 
     @classmethod
-    @logger_decorator("MODIN-ERROR", "ErrorMessage.not_implemented", "debug")
     def not_implemented(cls, message=""):
         if message == "":
             message = "This functionality is not yet available in Modin."
+        get_logger().info(f"Modin Error: NotImplementedError: {message}")
         raise NotImplementedError(
             f"{message}\n"
             + "To request implementation, file an issue at "
@@ -33,7 +33,6 @@ def not_implemented(cls, message=""):
         )
 
     @classmethod
-    @logger_decorator("MODIN-ERROR", "ErrorMessage.single_warning", "debug")
     def single_warning(cls, message):
         message_hash = hash(message)
         if message_hash in cls.printed_warnings:
@@ -43,7 +42,6 @@ def single_warning(cls, message):
         cls.printed_warnings.add(message_hash)
 
     @classmethod
-    @logger_decorator("MODIN-ERROR", "ErrorMessage.default_to_pandas", "debug")
     def default_to_pandas(cls, message=""):
         if message != "":
             message = f"{message} defaulting to pandas implementation."
@@ -57,14 +55,13 @@ def default_to_pandas(cls, message=""):
                 + "https://modin.readthedocs.io/en/stable/supported_apis/defaulting_to_pandas.html for explanation."
             )
             cls.printed_default_to_pandas = True
+        get_logger().debug(f"Modin Warning: Default to pandas: {message}")
         warnings.warn(message)
 
     @classmethod
-    @logger_decorator(
-        "MODIN-ERROR", "ErrorMessage.catch_bugs_and_request_email", "debug"
-    )
     def catch_bugs_and_request_email(cls, failure_condition, extra_log=""):
         if failure_condition:
+            get_logger().info(f"Modin Error: Internal Error: {extra_log}")
             raise Exception(
                 "Internal Error. "
                 + "Please visit https://github.com/modin-project/modin/issues "
@@ -74,23 +71,25 @@ def catch_bugs_and_request_email(cls, failure_condition, extra_log=""):
             )
 
     @classmethod
-    @logger_decorator("MODIN-ERROR", "ErrorMessage.non_verified_udf", "debug")
     def non_verified_udf(cls):
+        get_logger().debug("Modin Warning: Non Verified UDF")
         warnings.warn(
             "User-defined function verification is still under development in Modin. "
             + "The function provided is not verified."
         )
 
     @classmethod
-    @logger_decorator("MODIN-ERROR", "ErrorMessage.mismatch_with_pandas", "debug")
     def missmatch_with_pandas(cls, operation, message):
+        get_logger().debug(
+            f"Modin Warning: {operation} mismatch with pandas: {message}"
+        )
         cls.single_warning(
             f"`{operation}` implementation has mismatches with pandas:\n{message}."
         )
 
     @classmethod
-    @logger_decorator("MODIN-ERROR", "ErrorMessage.not_initialized", "debug")
     def not_initialized(cls, engine, code):
+        get_logger().debug(f"Modin Warning: Not Initialized: {engine}")
         warnings.warn(
             f"{engine} execution environment not yet initialized. Initializing...\n"
             + "To remove this warning, run the following python code before doing dataframe operations:\n"


Code review comments:
diff_hunk: @@ -33,7 +33,6 @@ def not_implemented(cls, message=""):
         )
 
     @classmethod
-    @logger_decorator("MODIN-ERROR", "ErrorMessage.single_warning", "debug")
     def single_warning(cls, message):
         message_hash = hash(message)
         if message_hash in cls.printed_warnings:
path: modin/error_message.py
text: @user1:
```suggestion
        if message_hash in cls.printed_warnings:
                get_logger().debug(f"Modin Warning: Warning `{message}` was raised and suppressed.")
```

diff_hunk: @@ -43,7 +42,6 @@ def single_warning(cls, message):
         cls.printed_warnings.add(message_hash)
path: modin/error_message.py
text: @user1:
```suggestion
        cls.printed_warnings.add(message_hash)
        get_logger().debug(f"Modin Warning: Warning `{message}` was raised.")
```