2

So the problem is this: I want to add logging so that we can track when a function starts executing, and when the function is done executing.

I suppose I could try and make Eclipse insert the logging calls at the start and end of a function, but because not everyone uses Eclipses, that didn't seem to be a great idea.

In Python, what I could've done is to write a decorator that takes *args and **kwargs, and either wrap them manually, or wrap all of them via inspection; or if i'm super lazy, I coupdl probably mess with __call__() to do what I need,

However, we're now working with java, and all the examples that I've seen requires me to declare an interface, which doesn't seem to be a good solution...

Any suggestions from java experts here?

Calyth
  • 1,673
  • 3
  • 16
  • 26

1 Answers1

3

You should look into AspectJ which uses Aspect Orientation to insert other code before/after your code.

There's an example code in the answer to this question: How to use AOP with AspectJ for logging?

Community
  • 1
  • 1
dkatzel
  • 31,188
  • 3
  • 63
  • 67