Uploaded image for project: 'SLF4J'
  1. SLF4J
  2. SLF4J-132

Need programmatic access to nested profiler or stopwatch

    XMLWordPrintable

Details

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • None
    • 1.5.x
    • slf4j-ext
    • None
    • Operating System: Linux
      Platform: PC

    Description

      I'd like to use Profiler to log the execution times of different parts of my (web)application, but I need to write out the times on a single line upon the completion of the client request.

      E.g., I need to see something similar to the following in my logfile:

      2009-07-14T15:06:07.364 3258/2342/234

      where ##/##/## stands for the time in ms for different parts of my application.

      To do that I would need to access programmatically the nested profilers created by Profiler.

      Ideally, I would have a getTimeInstrumentByName(String name) method on Profiler that would return a reference to the first sub-TimeInstrument of that name. It would be up to the developer to ensure that all sub-TimeInstruments are uniquely named. A possible implementation would be:

      public TimeInstrument getTimeInstrumentByName(String name) {
      for (TimeInstrument ti : childTimeInstrumentList) {
      if (ti instanceof StopWatch && name.equals(ti.getName())

      { return ti; }

      else

      { TimeInstrument result = ((Profiler)ti).getTimeInstrumentByName(name); if (null != result) return result; }

      }
      return null;
      }

      Attachments

        Activity

          People

            slf4j-dev SLF4J developers list
            lindelof@ieee.org David Lindelöf
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: