You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
caseclassExtendedTry[T](t: Try[T]) {
/** Logs a custom message in case of a failure of a given type, as a warning. * @parammessage The custom message to be logged. * @paramlog The logger instance is received implicitly or explicitly, such that it corresponds to the caller class. * @tparamE The type of exception to be matched against. * @return The same Try[T] instance, allowing it to chain operations.*/deflogFailure[E<:Throwable:ClassTag](message: String, withTrace: Boolean=false)(implicitlog: Logger)
:Try[T] = {
t.recover {
casefailure: E=> {
// Call here will print the file of the implicit Logger, but will print the line number in this file.if(withTrace) log.warn(failure)(message) else log.warn(s"$message : ${failure.getMessage}")
}
}
t
}
}
The text was updated successfully, but these errors were encountered:
Maybe, https://github.com/lihaoyi/sourcecode is a good candidate to provide such a feature. Notice, that sourcecode is also implemented by macros, thus it should not add to the runtime costs at all.
Is there any way to do something like this?
Reference:
http://stackoverflow.com/questions/1486233/java-logging-show-the-source-line-number-of-the-caller-not-the-logging-helper
Example use case:
The text was updated successfully, but these errors were encountered: