mirror of
https://github.com/corda/corda.git
synced 2025-06-17 22:58:19 +00:00
Add a startup banner and suppress console logging unless --log-to-console is passed on the command line.
This commit is contained in:
@ -4,7 +4,8 @@ package net.corda.core.utilities
|
||||
* A simple wrapper class that contains icons and support for printing them only when we're connected to a terminal.
|
||||
*/
|
||||
object Emoji {
|
||||
val hasEmojiTerminal by lazy { System.getenv("TERM") != null && (System.getenv("LANG")?.contains("UTF-8") == true) }
|
||||
// Unfortunately only Apple has a terminal that can do colour emoji AND an emoji font installed by default.
|
||||
val hasEmojiTerminal by lazy { System.getenv("TERM_PROGRAM") == "Apple_Terminal" }
|
||||
|
||||
const val CODE_DIAMOND = "\ud83d\udd37"
|
||||
const val CODE_BAG_OF_CASH = "\ud83d\udcb0"
|
||||
@ -13,12 +14,13 @@ object Emoji {
|
||||
const val CODE_LEFT_ARROW = "\u2b05\ufe0f"
|
||||
const val CODE_GREEN_TICK = "\u2705"
|
||||
const val CODE_PAPERCLIP = "\ud83d\udcce"
|
||||
const val CODE_COOL_GUY = "\ud83d\ude0e"
|
||||
|
||||
/**
|
||||
* When non-null, toString() methods are allowed to use emoji in the output as we're going to render them to a
|
||||
* sufficiently capable text surface.
|
||||
*/
|
||||
private val emojiMode = ThreadLocal<Any>()
|
||||
val emojiMode = ThreadLocal<Any>()
|
||||
|
||||
val diamond: String get() = if (emojiMode.get() != null) "$CODE_DIAMOND " else ""
|
||||
val bagOfCash: String get() = if (emojiMode.get() != null) "$CODE_BAG_OF_CASH " else ""
|
||||
@ -26,6 +28,16 @@ object Emoji {
|
||||
val rightArrow: String get() = if (emojiMode.get() != null) "$CODE_RIGHT_ARROW " else ""
|
||||
val leftArrow: String get() = if (emojiMode.get() != null) "$CODE_LEFT_ARROW " else ""
|
||||
val paperclip: String get() = if (emojiMode.get() != null) "$CODE_PAPERCLIP " else ""
|
||||
val coolGuy: String get() = if (emojiMode.get() != null) "$CODE_COOL_GUY " else ""
|
||||
|
||||
inline fun <T> renderIfSupported(body: () -> T): T {
|
||||
emojiMode.set(this) // Could be any object.
|
||||
try {
|
||||
return body()
|
||||
} finally {
|
||||
emojiMode.set(null)
|
||||
}
|
||||
}
|
||||
|
||||
fun renderIfSupported(obj: Any): String {
|
||||
if (!hasEmojiTerminal)
|
||||
|
Reference in New Issue
Block a user