+1 Lahiru.

Also if you are logging an object, make sure you are overriding toString()
method of the class. Otherwise the log is nothing but a garbage. Just got
this log on master branch.

*Rule executed for:
org.apache.stratos.autoscaler.context.partition.ClusterLevelPartitionContext@42c0a4d8*

ClusterLevelPartitionContext class doesn't override toString()  method.

Thanks.

On Mon, Feb 23, 2015 at 7:27 AM, Lahiru Sandaruwan <lahi...@wso2.com> wrote:

> Hi all,
>
> There are lot of different approaches of logging in Stratos code. May be
> we can follow same format so that code looks clean and understandable. This
> is to decide which way we should follow.
>
> *1. Separation of objects*
>
> We are using square brackets in most of the places. I think that is a good
> approach. May be we can use a comma after one object. We need to decide.
>
> E.g. 1
>
> [network-partition] network-partition-1 [cluster-instance]
> single-cartridge-app-1 [cluster] php1.php.domain
>
> E.g. 2
>
> [network-partition] network-partition-1, [cluster-instance]
> single-cartridge-app-1, [cluster] php1.php.domain
>
> *2. Using same text for identifying a particular type*
> E.g. We use [network-parition], [NW partition], [network partition] in
> different places. We could stick to one.
>
> *3. Using the String.format or concatenation. *
>
> String.format brings clarity and readability while it reduces the
> performance against concatenation. We need to decide what should be our
> choice. I would vote for String.format considering performance gain is
> negligible if we only have info level logs.
>
> *4. Use isDebugEnabled() and don't use isInfoEnabled()*
>
> Regarding this, we must use *isDebugEnabled* everywhere we do debug
> logging. But i think we can skip *isInfoEnabled *assuming we will have
> info logs in limited numbers. Wdyt?
>
> We can add a guidance at [2] for developers regarding all the matters
> here, after deciding.
>
> Thanks.
>
> [1]
> http://stackoverflow.com/questions/925423/is-it-better-practice-to-use-string-format-over-string-concatenation-in-java
> [2] https://cwiki.apache.org/confluence/display/STRATOS/Developer+Guide
> --
> --
> Lahiru Sandaruwan
> Committer and PMC member, Apache Stratos,
> Senior Software Engineer,
> WSO2 Inc., http://wso2.com
> lean.enterprise.middleware
>
> email: lahi...@wso2.com blog: http://lahiruwrites.blogspot.com/
> linked-in: http://lk.linkedin.com/pub/lahiru-sandaruwan/16/153/146
>
>


-- 
Rajkumar Rajaratnam
Committer & PMC Member, Apache Stratos
Software Engineer, WSO2

Mobile : +94777568639
Blog : rajkumarr.com

Reply via email to