-
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
4 changed files
with
47 additions
and
13 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
42 changes: 42 additions & 0 deletions
42
src/main/java/com/ryanmichela/sshd/ConsoleLogFormatter.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,42 @@ | ||
package com.ryanmichela.sshd; | ||
|
||
/** | ||
* Copyright 2013 Ryan Michela | ||
*/ | ||
|
||
import java.io.PrintWriter; | ||
import java.io.StringWriter; | ||
import java.text.SimpleDateFormat; | ||
import java.util.logging.Formatter; | ||
import java.util.logging.LogRecord; | ||
|
||
public class ConsoleLogFormatter extends Formatter { | ||
|
||
private SimpleDateFormat dateFormat; | ||
|
||
public ConsoleLogFormatter() { | ||
this.dateFormat = new SimpleDateFormat("HH:mm:ss"); | ||
} | ||
|
||
public String format(LogRecord logrecord) { | ||
StringBuilder stringbuilder = new StringBuilder(); | ||
|
||
stringbuilder.append(" ["); | ||
stringbuilder.append(this.dateFormat.format(Long.valueOf(logrecord.getMillis()))).append(" "); | ||
|
||
stringbuilder.append(logrecord.getLevel().getName()).append("]: "); | ||
stringbuilder.append(this.formatMessage(logrecord)); | ||
stringbuilder.append('\n'); | ||
Throwable throwable = logrecord.getThrown(); | ||
|
||
if (throwable != null) { | ||
StringWriter stringwriter = new StringWriter(); | ||
|
||
throwable.printStackTrace(new PrintWriter(stringwriter)); | ||
stringbuilder.append(stringwriter.toString()); | ||
} | ||
|
||
return stringbuilder.toString(); | ||
} | ||
} | ||
|
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