Chain-of-responsibility pattern: Difference between revisions

Content deleted Content added
m Java example: changed method name to make it more meaningful
m Java example: reverted method name to match other examples
Line 77:
}
 
static Logger createLoggerwriteLogger(LogLevel[] levels, Consumer<String> stringConsumer) {
EnumSet<LogLevel> set = EnumSet.copyOf(Arrays.asList(levels));
return (msg, severity) -> {
Line 87:
 
static Logger consoleLogger(LogLevel... levels) {
return createLoggerwriteLogger(levels, msg -> System.err.println("Writing to console: " + msg));
}
 
static Logger emailLogger(LogLevel... levels) {
return createLoggerwriteLogger(levels, msg -> System.err.println("Sending via email: " + msg));
}
 
static Logger fileLogger(LogLevel... levels) {
return createLoggerwriteLogger(levels, msg -> System.err.println("Writing to Log File: " + msg));
}