-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
99 additions
and
14 deletions.
There are no files selected for viewing
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
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
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
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
83 changes: 83 additions & 0 deletions
83
src/main/java/com/ryanmichela/sshd/StreamHandlerAppender.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package com.ryanmichela.sshd; | ||
|
||
import org.apache.logging.log4j.core.Appender; | ||
import org.apache.logging.log4j.core.ErrorHandler; | ||
import org.apache.logging.log4j.core.Layout; | ||
import org.apache.logging.log4j.core.LogEvent; | ||
|
||
import java.io.Serializable; | ||
import java.util.UUID; | ||
import java.util.logging.LogRecord; | ||
import java.util.logging.StreamHandler; | ||
|
||
/** | ||
* Copyright 2014 Ryan Michela | ||
*/ | ||
public class StreamHandlerAppender implements Appender { | ||
private StreamHandler streamHandler; | ||
private UUID uuid; | ||
|
||
public StreamHandlerAppender(StreamHandler streamHandler) { | ||
this.streamHandler = streamHandler; | ||
uuid = UUID.randomUUID(); | ||
} | ||
|
||
@Override | ||
public void append(LogEvent logEvent) { | ||
java.util.logging.Level level; | ||
switch (logEvent.getLevel()) | ||
{ | ||
case DEBUG: level = java.util.logging.Level.FINE; break; | ||
case INFO: level = java.util.logging.Level.INFO; break; | ||
case WARN: level = java.util.logging.Level.WARNING; break; | ||
case ERROR: level = java.util.logging.Level.SEVERE; break; | ||
default: level = java.util.logging.Level.INFO; break; | ||
} | ||
|
||
String message = logEvent.getMessage().getFormattedMessage(); | ||
|
||
|
||
LogRecord logRecord = new LogRecord(level, message); | ||
streamHandler.publish(logRecord); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "StreamHandlerAppender:" + uuid.toString(); | ||
} | ||
|
||
@Override | ||
public Layout<? extends Serializable> getLayout() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public boolean ignoreExceptions() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public ErrorHandler getHandler() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public void setHandler(ErrorHandler errorHandler) { | ||
|
||
} | ||
|
||
@Override | ||
public void start() { | ||
|
||
} | ||
|
||
@Override | ||
public void stop() { | ||
|
||
} | ||
|
||
@Override | ||
public boolean isStarted() { | ||
return true; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: SSHD | ||
version: "1.0" | ||
version: "1.1" | ||
author: Ryan Michela | ||
main: com.ryanmichela.sshd.SshdPlugin |