Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java code instrumentation using annotations

I've got a huge java project with tons of code. Let us assume it looks like:

fn1(int arg1){...}
fn2(int arg1,int arg2){...}
fn23(){...}
...
fn134(){...}

I want to log each invocation of functions using annotations:

@logme("arg1")
fn1(int arg1){...}
@logme("all args")
fn2(int arg1,int arg2){...}
fn23(){...}
...
fn134(){...}

and expect seeing

fn1(arg1=223)
fn1(arg1=213,arg2=46)

in my log files

Would you be so kind to propose me some tool?

Steve

like image 244
Stepan Yakovenko Avatar asked Jul 28 '26 10:07

Stepan Yakovenko


1 Answers

I would recommend to use AspectJ for this purpose. Here you can find a short documentation how to define the appropriate PointCuts

like image 56
RoflcoptrException Avatar answered Aug 01 '26 10:08

RoflcoptrException



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!