logging is cluttering my "beautiful" clean simple short code. instead of a simple
def mymethod = dosomething // scala
my code is also having also all these nasty logging statements which and immediately i have to add new lines and curly braces to mymethod
.
now i don't like AOP
it would just make clear code --> unclear.
anyway to get over this? I have when simple code turns to less simple, but i also need logging. help.
how to make this code clear simple short and also with logging?
A typical approach in functional programming would be to add a higher-order logging combinator.
log :: IO a -> String -> IO a
log f s = do
v <- f
print ("My message: " ++ s)
return v
Such a wrapper augments evaluation of a function with a log message.
The general pattern is \x y -> .. something with y .. return x
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With