Uploaded image for project: 'Felix'
  1. Felix
  2. FELIX-1186

Defer the construction of a log message

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Trivial
    • Resolution: Fixed
    • scr-1.0.8
    • scr-1.2.0
    • None

    Description

      There are a lot of log messages at the DEBUG level constructed in the first place.

      My thinking is to put the construction of a message after the threshold of the log level is compared to, which could improve the performance and especially means much on a resource constrained device.

      Since most of the log message is constructed by simply concatenating String values of several objects, the prototype of the method BundleComponentActivator.log(a singleton utility may be better) could be like the following.

      public void log( int level, ComponentMetadata metadata, Throwable ex, Object... objs );

      And because most messages consist of no more than 3 objects, we can even implement 3 more log methods as follows to avoid the creation of an object array.

      public void log( int level, ComponentMetadata metadata, Throwable ex, Object obj );

      public void log( int level, ComponentMetadata metadata, Throwable ex, Object obj0, Object obj1 );

      public void log( int level, ComponentMetadata metadata, Throwable ex, Object obj0, Object obj1, Object obj2 );

      And the final log message can be constructed after "if ( m_logLevel >= level )".

      Attachments

        Activity

          People

            fmeschbe Felix Meschberger
            agemocui Agemo Cui
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: