Enhances logging of exceptions by including the full stack trace in addition to the exception message

MSAL

It is a common mistake to call Exception.getMessage() when passing an exception into a log method. Not all exception types have useful messages, and even if the message is useful this omits the stack trace. Including a complete stack trace of the error along with the exception message in the log allows developers to better understand the context of the exception and identify the source of the error more quickly and accurately. If the method invocation includes any call to Exception.getMessage() or Exception.getLocalizedMessage() and not an exception is already passed as the last parameter to the log method, then we will append the exception as the last parameter in the log method. Additionally, if an exception is passed directly as a format argument that fills a {} placeholder, the placeholder is removed so that the exception is treated as the trailing argument, ensuring the full stack trace is logged.

org.openrewrite.java.logging.slf4j.CompleteExceptionLogging
mod run . --recipe=org.openrewrite.java.logging.slf4j.CompleteExceptionLogging

Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.