Anish
Anish

Reputation: 255

Eclipse plugin for Java that automatically adds logging events

I want to add a plugin to my Eclipse(Helios) which logs my function start and end. To be more precise, I'm looking for something like this.

TestClass {

    private static final Logger logger = Logger.getLog("TestClass");

    public void displayHello () {
        System.out.println("Fooo");
    }
}

After I add the plugin and enable functional logging,Im expecting the following

TestClass {
  private static final Logger logger = Logger.getLog("TestClass");
   public void displayHello () {
     logger.debug ("displayHello() - Started");
     System.out.println("Fooo");
     logger.debug ("displayHello() - Ended");
   }
 }

I remember using some method to obtain the same earlier but am unable to recollect the same now.Can anyone help me out with this?

Thanks Anish

Upvotes: 3

Views: 751

Answers (2)

Andrew Eisenberg
Andrew Eisenberg

Reputation: 28737

Since the question is about Eclipse plugins, I am assuming that the places you want to log do not necessarily exist in a single plugin. AspectJ is a good suggestion. However, standard AspectJ or Spring AOP will not be sufficient since it is classloader based. You will need to use Equinox Weaving.

Equinox Weaving performs load-time weaving in an OSGi-aware way. Essentially, you create your plugins and augment your manifest files with the proper weaving configuration.

Upvotes: 0

Jayamohan
Jayamohan

Reputation: 12924

You should look at AspectJ and Spring AOP its supports something like this,

execution(* com.java.test..*.*(..))

which will cover all methods in all sub-packages of project. So no need to define all methods one by one.

Upvotes: 2

Related Questions