com.ibm.ecm.sample.webhook.util

Class WebhookReceiverLogger

  • java.lang.Object
    • com.ibm.ecm.sample.webhook.util.WebhookReceiverLogger


  • public class WebhookReceiverLogger
    extends java.lang.Object
    Collection of utility methods for handling logging with the Apache logger. In a real-life application, it is a good idea to filter out newline and HTML characters, as user provided strings could potentially contain fake log messages (CWE-117: Improper Output Neutralization for Logs). The sample application has the code commented out, as the response JSON from the GraphQL API logged in the debug trace is easier to read with newline characters. If this application is used as the bases for a real application, it would be good to edit the build.gradle file to add the commons-lang library, import org.apache.commons.lang.StringEscapeUtils, and uncomment the relevant code in filter(String).
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method and Description
      static void debug(java.lang.String... messages)
      Logs a message with the debug log level.
      static void entering(java.lang.String className, java.lang.String methodName)
      Logs a message with the trace log level.
      static void error(java.lang.String... messages)
      Logs a message with the error log level.
      static void error(java.lang.String message, java.lang.Throwable t)
      Logs a message and a relevant exception that prompted the message with the error log level.
      static void exiting(java.lang.String className, java.lang.String methodName)
      Logs a message with the trace log level.
      static void info(java.lang.String... messages)
      Logs a message with the info log level.
      static void throwing(java.lang.String msg, java.lang.Throwable t)
      Logs a trace message when the code is about to throw an exception.
      static void trace(java.lang.String... messages)
      Logs a message with the trace log level.
      static void warn(java.lang.String... messages)
      Logs a message with the warn log level.
      static void warn(java.lang.String message, java.lang.Throwable t)
      Logs a message and a relevant exception that prompted the message with the warn log level.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • WebhookReceiverLogger

        public WebhookReceiverLogger()
    • Method Detail

      • info

        public static void info(java.lang.String... messages)
        Logs a message with the info log level. If multiple messages are specified, the messages will be appended before being logged.
        Parameters:
        messages - the set of messages to log
      • warn

        public static void warn(java.lang.String... messages)
        Logs a message with the warn log level. If multiple messages are specified, the messages will be appended before being logged.
        Parameters:
        messages - the set of messages to log
      • warn

        public static void warn(java.lang.String message,
                                java.lang.Throwable t)
        Logs a message and a relevant exception that prompted the message with the warn log level. If multiple messages are specified, the messages will be appended before being logged.
        Parameters:
        message - the message to log
        t - cause to log with the message
      • error

        public static void error(java.lang.String... messages)
        Logs a message with the error log level. If multiple messages are specified, the messages will be appended before being logged.
        Parameters:
        messages - the set of messages to log
      • error

        public static void error(java.lang.String message,
                                 java.lang.Throwable t)
        Logs a message and a relevant exception that prompted the message with the error log level. If multiple messages are specified, the messages will be appended before being logged.
        Parameters:
        message - the message to log
        t - cause to log with the message
      • throwing

        public static void throwing(java.lang.String msg,
                                    java.lang.Throwable t)
        Logs a trace message when the code is about to throw an exception. The exception will typically be caught by higher level code and logged as an error but logging a trace message at the point when the exception is thrown is a way to ensure that important information doesn't get lost if the higher level code doesn't log the error for some reason. Tracing can always be enabled to capture more information if the expected detail isn't in the normal log.
        Parameters:
        msg - Message to log with the exception
        t - Exception to log
      • trace

        public static void trace(java.lang.String... messages)
        Logs a message with the trace log level. If multiple messages are specified, the messages will be appended before being logged.
        Parameters:
        messages - the set of messages to log
      • debug

        public static void debug(java.lang.String... messages)
        Logs a message with the debug log level. If multiple messages are specified, the messages will be appended before being logged.
        Parameters:
        messages - the set of messages to log
      • entering

        public static void entering(java.lang.String className,
                                    java.lang.String methodName)
        Logs a message with the trace log level. The message will be used to indicate the start of a given method from a given class
        Parameters:
        className - Name of the class to which the logging method belongs
        methodName - Name of the method that was just started
      • exiting

        public static void exiting(java.lang.String className,
                                   java.lang.String methodName)
        Logs a message with the trace log level. The message will be used to indicate the end of a given method from a given class
        Parameters:
        className - Name of the class to which the logging method belongs
        methodName - Name of the method that just finished