[ 
https://issues.apache.org/jira/browse/FELIX-1186?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12713986#action_12713986
 ] 

Felix Meschberger commented on FELIX-1186:
------------------------------------------

Good idea. I would follow the SLF4J way, though and do it like this:

    public void log(int, ComponentMetadata, Throwable, String message, Object[] 
args)

with helpers for one, two, and maybe three arguments. The message would 
probably be a format string for java.text.MessageFormat.

I would not use the Java 5 varargs style (for now) because we like to keep our 
core stuff 1.4 (if not 1.3) compliant.

Regarding the singleton utility:  I am not so sure, since the 
BundleComponentActivator uses a LogService acquired through the BundleContext 
of the component declaring bundle.

Can you provide a patch for this ?

> 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