Created
November 19, 2014 22:41
-
-
Save dkowis/ba906337a2e787ddde2f to your computer and use it in GitHub Desktop.
An example to wrap it instead of copy/pasting try/finally on each one. Same effect as calling a function in try/finally, but you can do more
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
def withContext(f: LoggingServiceImpl => Unit) = { | |
val loggingService = new LoggingServiceImpl() | |
val context = LogManager.getContext(false).asInstanceOf[LoggerContext] | |
try { | |
f(loggingService) | |
} finally { | |
System.clearProperty(ConfigurationFactory.CONFIGURATION_FILE_FACTORY) | |
context.reconfigure | |
StatusLogger.getLogger.reset | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment