Class TraceCompassLogUtils.ScopeLog

java.lang.Object
org.eclipse.tracecompass.common.core.log.TraceCompassLogUtils.ScopeLog
All Implemented Interfaces:
AutoCloseable
Enclosing class:
TraceCompassLogUtils

public static class TraceCompassLogUtils.ScopeLog extends Object implements AutoCloseable
Scope Logger helper. This will automatically log entry and exit of the scope. This scope log will be shown under any scope enclosing it, but will not be the source, or destination of any link to other scopes. If relations should be done with other scopes, the TraceCompassLogUtils.FlowScopeLog class is more appropriate. Usage:
 usage of ScopeLog
  try (ScopeLog linksLogger = new ScopeLog(LOGGER, Level.CONFIG, "Perform Query")) { //$NON-NLS-1$
      ss.updateAllReferences();
      dataStore.addAll(ss.query(ts, trace));
  }
 

will generate the following trace

 trace output
  INFO: {"ts":12345,"ph":"B",tid:1,"name:Perform Query"}
  INFO: {"ts":"12366,"ph":"E","tid":1}
 
  • Constructor Details

    • ScopeLog

      public ScopeLog(Logger log, Level level, String label, Object... args)
      Scope logger constructor
      Parameters:
      log - the JUL logger to log to
      level - the log level see Level
      label - The label of the event pair
      args - Additional messages to pass for this scope, should be in pairs key, value, key2, value2.... typically arguments. Note that these arguments will be logged only at the beginning of the scope
  • Method Details

    • addData

      public void addData(String name, Object value)
      Add a tag to the scope logger, will be written at the exit. This can save space on the trace by having a field appended to an event rather than writing a whole new event for a small chunk of data. If the timing information is important than it would be more appropriate to call TraceCompassLogUtils.traceInstant(Logger, Level, String, Object...)
      Parameters:
      name - the name of the field
      value - The value of the field.
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable