Last active
June 23, 2017 09:38
-
-
Save frgomes/13599efd7e6f2dc5a7b0528615cbdd14 to your computer and use it in GitHub Desktop.
Finatra : wrap service by a LoggingFilter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// build.sbt here: https://gist.github.com/frgomes/fb4ca804c21dd14e3224e4fc23d377e6 | |
//TODO: should take configurations from configuration Logger in the environment. | |
def logWrapper(service: Service[Request, Response]): Service[Request, Response] = { | |
import com.twitter.logging._ | |
import com.twitter.finagle.http.filter.{CommonLogFormatter, LoggingFilter} | |
val factory = LoggerFactory( | |
node = "", | |
level = Some(Level.TRACE), | |
handlers = List( | |
FileHandler( | |
filename = "log/oauth2.log", | |
rollPolicy = Policy.SigHup | |
) | |
) | |
) | |
val logger = factory() | |
val stringHandler = new StringHandler(BareFormatter, Some(Logger.DEBUG)) | |
logger.addHandler(stringHandler) | |
logger.setUseParentHandlers(false) | |
val formatter = new CommonLogFormatter | |
val wrapper: Service[Request, Response] = (new LoggingFilter(logger, formatter)) andThen service | |
wrapper | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment