There are lot of log statements in some important method, they are used to log the progress and some important information.
val result = user.login()
if(result) {
logger.info("User has logged in successful: " + user.id)
val questions = user.queryQuestions()
logger.info("User has " + questions.size + " questions")
val latestQuestion = questions.headOption
logger.info("The latest question is: " + latestQuestion)
...
} else {
logger.info("User has logged failed: " + user.id)
}
Suppose all the log information are very important, they need to be logged and audit. But the code looks like Java rather than Scala.
How can we improve it so it looks more functional and less side-effect?