eclipselabs / passerelle

Passerelle, an actor-based process engine based on Ptolemy II
5 stars 3 forks source link

Suggestion: new Actor method logInfo #37

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hi,

As I mentioned briefly in the Passerelle meeting in Gent recently I have added 
in the DAWN Passerelle repositories a new method to Actor.java:

   * Generic log method for all actors. The idea is to harmonize the log
   * message, if in 'info' level add the actor name and if in 'trace' or 'debug'
   * level add the full name.
   * 
   */
  public void logInfo(String logMessage) {
    if (LOGGER.isInfoEnabled())
        LOGGER.info( logMessage + " (actor '" + this.getName() + "')");
    else if (LOGGER.isTraceEnabled() || LOGGER.isDebugEnabled())
        LOGGER.info( logMessage + " (actor '" + this.getFullName() + "')");
  }

There are two aims with this method:

- The info log output of actors are harmonized, i.e. they look similar

- In debug mode more info is added (i.e. full name)

The idea is also to use this method with Jmx, possibly via the 
ExecutionTracerService.

Would it be possible for you to add this method into Actor.java in the main SVN 
Psserelle repository? Please let me know if you have other suggestions.

Regards,

Olof

Original issue reported on code.google.com by s.olof.svensson@gmail.com on 30 Nov 2012 at 8:38

GoogleCodeExporter commented 9 years ago
Hi Olof,

We prefer to have the actor's name in front of the logged message.

Also, in your code I have the impression that it would never reach the 
trace/debug part as the isInfoEnabledd will also trigger then?

So I would do something like :

public void logInfo(String logMessage) {
    if (LOGGER.isTraceEnabled() || LOGGER.isDebugEnabled())
        LOGGER.debug( this.getFullName() + " - " + logMessage);
    else if (LOGGER.isInfoEnabled())
        LOGGER.info( this.getName() + " - " + logMessage);
  }

Original comment by erwin...@gmail.com on 5 Dec 2012 at 8:05

GoogleCodeExporter commented 9 years ago
Hi Erwin,

I agree with your changes. Thanks in advance for adding this code to the 
Passerelle repository!

Olof

Original comment by s.olof.svensson@gmail.com on 5 Dec 2012 at 12:34

GoogleCodeExporter commented 9 years ago
done.

Original comment by erwin...@gmail.com on 9 Dec 2012 at 2:55