Developing Conventions

39.1. Code logging conventions

The ProActive code is currently using log4j as logging service. The purpose of this chapter is to assist developers for adding a valuable logging system in their codes. Furthermore, this page aims to fix logging conventions as rules. The main goal is to have an undifferentiated and powerful logging service for a useful using of log messages that's why everybody must apply these rules.

39.1.1. Declaring loggers name

The interface org.objectweb.proactive.core.util.Loggers contains all loggers' name as constants (public static final String). All loggers' name must start with proactive. It is the root logger. Therefore all loggers are hierarchic.

/** Root logger for ProActive P2P. **/
public static final String P2P = "proactive.p2p";

/** Sub logger for starting P2P service. */
public static final String P2P_STARTSERVICE = P2P + ".startservice";

/** Sub logger for P2P acquaintances managing. */
public static final String P2P_ACQUAINTANCES = P2P + ".acquaintances";

/** Sub logger for P2P first contact step. */
public static final String P2P_FIRST_CONTACT = P2P + ".first_contact";

Example 39.1. declaring P2P loggers in the interface org.objectweb.proactive.core.util.Loggers


39.1.2. Using declared loggers in your classes

Firstly, import good classes:

import org.objectweb.proactive.core.util.log.ProActiveLogger;
import org.objectweb.proactive.core.util.log.Loggers;

Secondly, get the logger or loggers:

private static final ProActiveLogger logger_acq =
 ProActiveLogger.getLogger(Loggers.P2P_ACQUAINTANCES);

Thirdly, log your code:

if (logger.isDeubugEnable()) {
          logger_acq.debug("message log debug  level for P2P acquaintances managing");
       }

Override logging methods in ProActiveLogger. Use this class to add some specific treatments to log messages.

39.1.3. Managing loggers

Using hierarchic loggers is realy helpful to choose which logging level for what is logged. In the log4j configuration file, typicaly proactive-log4j, set level of loggers, such as:

# All logger at debug level
log4j.logger.proactive = DEBUG
# and P2P logger only info level is needed
log4j.logger.proactive.p2p = INFO
#For P2P first contact step needs only fatal messages
log4j.logger.proactive.p2p..first_contact = FATAL 

39.1.4. Logging output

Enabling the name of the category using for instance [%c] facilitates the understanding of the logging output.

[proactive.p2p.service] DEBUG [P2PService on //trinidad.inria.fr:3000/P2PNode]: Heart-beat message received

Here we can clearly see:

  • a p2p.service log,

  • at debugging level,

  • received from the thread P2PService on trinidad/P2PNode,

  • and the log message.

39.1.5. More information about log4j

39.2. Regression Tests Writing

Add your test in nonregressiontest package and run all tests before committing with compile/build.sh runTestsLocal.

39.3. Committing modifications in the SVN

You need to do several things:

  1. Get a recent PA version : svn co svn+ssh://[email protected]/svn/proactive/trunk ProActive (use your login)

  2. Clean up your version : run the command 'build clean all format' this should compile with no errors and will also format the files with the OASIS formatting rules

  3. Make sure you have integrated the latest modifications of others. For that, you may try

    • with eclipse, a team -> synchronize. This view shows conflicts.

    • with the shell, svn update -dP changes files if there is no conflict, and tells you which files are conflicting.

  4. Commit the files, making bunches for functionalities. If, to add the functionality "foo", you've modified files A, B, and C.java, your commit should be of these 3 files, and should contain a description of "foo"