Class Console


  • public final class Console
    extends Object
    Helper class for using window.console. Does not log anything to console if production mode is enabled.
    Since:
    1.0
    Author:
    Vaadin Ltd
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void debug​(Object message)
      If not in production mode, logs the given message to the browser console using the debug log level.
      static void error​(Object message)
      If not in production mode, logs the given message to the browser console using the error log level.
      static void log​(Object message)
      If not in production mode, logs the given message to the browser console using the info log level.
      static void reportStacktrace​(Exception exception)
      Logs the stacktrace of an exception to the browser console.
      static void setProductionMode​(boolean isProductionMode)
      Changes logger behavior, making it skip all browser logging for production mode.
      static void warn​(Object message)
      If not in production mode, logs the given message to the browser console using the warning log level.
    • Method Detail

      • setProductionMode

        public static void setProductionMode​(boolean isProductionMode)
        Changes logger behavior, making it skip all browser logging for production mode.
        Parameters:
        isProductionMode - if an application is in the production mode or not
      • debug

        public static void debug​(Object message)
        If not in production mode, logs the given message to the browser console using the debug log level.

        If used directly in a JVM, writes the message to standard output disregarding of the production mode settings.

        Parameters:
        message - the message to log
      • log

        public static void log​(Object message)
        If not in production mode, logs the given message to the browser console using the info log level.

        If used directly in a JVM, writes the message to standard output disregarding of the production mode settings.

        Parameters:
        message - the message to log
      • warn

        public static void warn​(Object message)
        If not in production mode, logs the given message to the browser console using the warning log level.

        If used directly in a JVM, writes the message to standard error disregarding of the production mode settings.

        Parameters:
        message - the message to log
      • error

        public static void error​(Object message)
        If not in production mode, logs the given message to the browser console using the error log level.

        If used directly in a JVM, writes the message to standard error disregarding of the production mode settings.

        Parameters:
        message - the message to log
      • reportStacktrace

        public static void reportStacktrace​(Exception exception)
        Logs the stacktrace of an exception to the browser console. Logging is done asynchronously since that approach allows reporting it with highest possible fidelity.
        Parameters:
        exception - the exception for which