Class Trace

java.lang.Object
org.h2.message.Trace

public final class Trace extends Object
This class represents a trace module.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    The trace module id for commands.
    static final int
    The trace module id for constraints.
    static final int
    The trace module id for databases.
    static final int
    The trace module id for file locks.
    static final int
    The trace module id for functions.
    static final int
    The trace module id for indexes.
    static final int
    The trace module id for the JDBC API.
    static final int
    The trace module id for the JDBCX API
    private final String
     
    static final int
    The trace module id for locks.
    private final String
     
    static final String[]
    Module names by their ids as array indexes.
    static final int
    The trace module id for schemas.
    static final int
    The trace module id for sequences.
    static final int
    The trace module id for settings.
    static final int
    The trace module id for tables.
    private int
     
    private final TraceWriter
     
    static final int
    The trace module id for triggers.
    static final int
    The trace module id for users.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Trace(TraceWriter traceWriter, int moduleId)
     
    Trace(TraceWriter traceWriter, String module)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Write a message with trace level DEBUG to the trace system.
    void
    debug(String s, Object... params)
    Write a message with trace level DEBUG to the trace system.
    void
    Write a message with trace level DEBUG to the trace system.
    (package private) void
    Write Java source code with trace level DEBUG to the trace system.
    void
    Write a message with trace level ERROR to the trace system.
    void
    error(Throwable t, String s, Object... params)
    Write a message with trace level ERROR to the trace system.
    static String
    formatParams(ArrayList<? extends ParameterInterface> parameters)
    Format the parameter list.
    void
    Write a message with trace level INFO to the trace system.
    void
    info(String s, Object... params)
    Write a message with trace level INFO to the trace system.
    (package private) void
    Write a message with trace level INFO to the trace system.
    void
    Write Java source code with trace level INFO to the trace system.
    void
    infoSQL(String sql, String params, long count, long time)
    Write a SQL statement with trace level INFO to the trace system.
    boolean
    Check if the trace level is equal or higher than DEBUG.
    private boolean
    isEnabled(int level)
     
    boolean
    Check if the trace level is equal or higher than INFO.
    void
    setLevel(int level)
    Set the trace level of this component.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • COMMAND

      public static final int COMMAND
      The trace module id for commands.
      See Also:
    • CONSTRAINT

      public static final int CONSTRAINT
      The trace module id for constraints.
      See Also:
    • DATABASE

      public static final int DATABASE
      The trace module id for databases.
      See Also:
    • FUNCTION

      public static final int FUNCTION
      The trace module id for functions.
      See Also:
    • FILE_LOCK

      public static final int FILE_LOCK
      The trace module id for file locks.
      See Also:
    • INDEX

      public static final int INDEX
      The trace module id for indexes.
      See Also:
    • JDBC

      public static final int JDBC
      The trace module id for the JDBC API.
      See Also:
    • LOCK

      public static final int LOCK
      The trace module id for locks.
      See Also:
    • SCHEMA

      public static final int SCHEMA
      The trace module id for schemas.
      See Also:
    • SEQUENCE

      public static final int SEQUENCE
      The trace module id for sequences.
      See Also:
    • SETTING

      public static final int SETTING
      The trace module id for settings.
      See Also:
    • TABLE

      public static final int TABLE
      The trace module id for tables.
      See Also:
    • TRIGGER

      public static final int TRIGGER
      The trace module id for triggers.
      See Also:
    • USER

      public static final int USER
      The trace module id for users.
      See Also:
    • JDBCX

      public static final int JDBCX
      The trace module id for the JDBCX API
      See Also:
    • MODULE_NAMES

      public static final String[] MODULE_NAMES
      Module names by their ids as array indexes.
    • traceWriter

      private final TraceWriter traceWriter
    • module

      private final String module
    • lineSeparator

      private final String lineSeparator
    • traceLevel

      private int traceLevel
  • Constructor Details

  • Method Details

    • setLevel

      public void setLevel(int level)
      Set the trace level of this component. This setting overrides the parent trace level.
      Parameters:
      level - the new level
    • isEnabled

      private boolean isEnabled(int level)
    • isInfoEnabled

      public boolean isInfoEnabled()
      Check if the trace level is equal or higher than INFO.
      Returns:
      true if it is
    • isDebugEnabled

      public boolean isDebugEnabled()
      Check if the trace level is equal or higher than DEBUG.
      Returns:
      true if it is
    • error

      public void error(Throwable t, String s)
      Write a message with trace level ERROR to the trace system.
      Parameters:
      t - the exception
      s - the message
    • error

      public void error(Throwable t, String s, Object... params)
      Write a message with trace level ERROR to the trace system.
      Parameters:
      t - the exception
      s - the message
      params - the parameters
    • info

      public void info(String s)
      Write a message with trace level INFO to the trace system.
      Parameters:
      s - the message
    • info

      public void info(String s, Object... params)
      Write a message with trace level INFO to the trace system.
      Parameters:
      s - the message
      params - the parameters
    • info

      void info(Throwable t, String s)
      Write a message with trace level INFO to the trace system.
      Parameters:
      t - the exception
      s - the message
    • formatParams

      public static String formatParams(ArrayList<? extends ParameterInterface> parameters)
      Format the parameter list.
      Parameters:
      parameters - the parameter list
      Returns:
      the formatted text
    • infoSQL

      public void infoSQL(String sql, String params, long count, long time)
      Write a SQL statement with trace level INFO to the trace system.
      Parameters:
      sql - the SQL statement
      params - the parameters used, in the for {1:...}
      count - the update count
      time - the time it took to run the statement in ms
    • debug

      public void debug(String s, Object... params)
      Write a message with trace level DEBUG to the trace system.
      Parameters:
      s - the message
      params - the parameters
    • debug

      public void debug(String s)
      Write a message with trace level DEBUG to the trace system.
      Parameters:
      s - the message
    • debug

      public void debug(Throwable t, String s)
      Write a message with trace level DEBUG to the trace system.
      Parameters:
      t - the exception
      s - the message
    • infoCode

      public void infoCode(String java)
      Write Java source code with trace level INFO to the trace system.
      Parameters:
      java - the source code
    • debugCode

      void debugCode(String java)
      Write Java source code with trace level DEBUG to the trace system.
      Parameters:
      java - the source code