I like scala as it can help me have cleaner code.
However while logging i feel my code gets cluttered...
def myFunc(args) = {
log.trace("entering myfunc, args are ... ")
val result = doSomething()
log.info("I really want to print that result which is {}", result)
log.trace("exiting myfunc result {}", result)
result
}
as you can see instead of just calling
def myFunc(args) = doSoemthing
I needed to split the result into a var
so that i can first log it and only then return it.
now that was a simple use case in more complex use cases I have more loggings in my methods, some info
some debug
things become more complex and code becomes much more cluttered
due to logging..
while I could wrap my method with another method which would add logging on entry and exit this would make my code more complex so i'm looking for a very clean logging solution not focusing only on method entry and exit (I dont want to use AOP because it makes code also more compelx and hard to understand).
how to unclutter code while still having code simple and easy to understand with powerful logging? (solution not invented yet?) or is there a true clean solution?