Defer the construction of a log message
---------------------------------------

                 Key: FELIX-1186
                 URL: https://issues.apache.org/jira/browse/FELIX-1186
             Project: Felix
          Issue Type: Improvement
          Components: Declarative Services (SCR)
    Affects Versions: scr-1.0.8
            Reporter: Agemo Cui
            Priority: Trivial


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 )".




-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to