-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #137 from libp2p/0.5.6
Release 0.5.6 #136 (Fix the panic when SemiDuplex has no outbound stream yet)
- Loading branch information
Showing
9 changed files
with
126 additions
and
8 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
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
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,32 @@ | ||
package io.libp2p.tools | ||
|
||
import org.apache.logging.log4j.Level | ||
import org.apache.logging.log4j.LogManager | ||
import org.apache.logging.log4j.core.LogEvent | ||
import org.apache.logging.log4j.core.Logger | ||
import org.apache.logging.log4j.core.appender.AbstractAppender | ||
import java.util.ArrayList | ||
|
||
class TestLogAppender : AbstractAppender("test", null, null), AutoCloseable { | ||
val logs: MutableList<LogEvent> = ArrayList() | ||
|
||
fun install(): TestLogAppender { | ||
(LogManager.getRootLogger() as Logger).addAppender(this) | ||
return this | ||
} | ||
|
||
fun uninstall() { | ||
(LogManager.getRootLogger() as Logger).removeAppender(this) | ||
} | ||
|
||
override fun close() { | ||
uninstall() | ||
} | ||
|
||
fun hasAny(level: Level) = logs.any { it.level == level } | ||
fun hasAnyWarns() = hasAny(Level.ERROR) || hasAny(Level.WARN) | ||
|
||
override fun append(event: LogEvent) { | ||
logs += event.toImmutable() | ||
} | ||
} |