Package org.jboss.logmanager.formatters
Class TextBannerFormatter
- java.lang.Object
-
- java.util.logging.Formatter
-
- org.jboss.logmanager.ExtFormatter
-
- org.jboss.logmanager.ExtFormatter.Delegating
-
- org.jboss.logmanager.formatters.TextBannerFormatter
-
public final class TextBannerFormatter extends ExtFormatter.Delegating
A formatter which prints a text banner ahead of the normal formatter header. The text banner is acquired from aSupplier
which is passed in to the constructor. Several utility methods are also present which allow easy creation ofSupplier
instances.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.jboss.logmanager.ExtFormatter
ExtFormatter.Delegating
-
-
Field Summary
-
Fields inherited from class org.jboss.logmanager.ExtFormatter.Delegating
delegate
-
-
Constructor Summary
Constructors Constructor Description TextBannerFormatter(Supplier<String> bannerSupplier, ExtFormatter delegate)
Construct a new instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Supplier<String>
createFileSupplier(Path path, Supplier<String> fallback)
Create a supplier which loads the banner from the given file path, falling back to the given fallback supplier on error.static Supplier<String>
createResourceSupplier(String resource, ClassLoader classLoader, Supplier<String> fallback)
Create a supplier which loads the banner from a resource in the given class loader, falling back to the given fallback supplier on error.static Supplier<String>
createResourceSupplier(String resource, Supplier<String> fallback)
Create a supplier which loads the banner from a resource in the caller's class loader, falling back to the given fallback supplier on error.static Supplier<String>
createStringSupplier(String string)
Create a supplier which always returns the given string.static Supplier<String>
createUrlSupplier(URL url, Supplier<String> fallback)
Create a supplier which loads the banner from the given URL, falling back to the given fallback supplier on error.static Supplier<String>
getEmptySupplier()
Get the empty supplier which always returns an empty string.String
getHead(Handler h)
-
Methods inherited from class org.jboss.logmanager.ExtFormatter.Delegating
format, formatMessage, getTail, isCallerCalculationRequired
-
Methods inherited from class org.jboss.logmanager.ExtFormatter
format, formatMessageLegacy, formatMessageNone, formatMessagePrintf, wrap
-
-
-
-
Constructor Detail
-
TextBannerFormatter
public TextBannerFormatter(Supplier<String> bannerSupplier, ExtFormatter delegate)
Construct a new instance.- Parameters:
bannerSupplier
- the supplier for the banner (must not benull
)delegate
- the delegate formatter (must not benull
)
-
-
Method Detail
-
getHead
public String getHead(Handler h)
- Overrides:
getHead
in classExtFormatter.Delegating
-
getEmptySupplier
public static Supplier<String> getEmptySupplier()
Get the empty supplier which always returns an empty string.- Returns:
- the empty supplier (not
null
)
-
createStringSupplier
public static Supplier<String> createStringSupplier(String string)
Create a supplier which always returns the given string.- Parameters:
string
- the string (must not benull
)- Returns:
- a supplier which returns the given string (not
null
)
-
createFileSupplier
public static Supplier<String> createFileSupplier(Path path, Supplier<String> fallback)
Create a supplier which loads the banner from the given file path, falling back to the given fallback supplier on error.- Parameters:
path
- the path to load from (must not benull
)fallback
- the fallback supplier (must not benull
)- Returns:
- the supplier (not
null
)
-
createUrlSupplier
public static Supplier<String> createUrlSupplier(URL url, Supplier<String> fallback)
Create a supplier which loads the banner from the given URL, falling back to the given fallback supplier on error.- Parameters:
url
- the URL to load from (must not benull
)fallback
- the fallback supplier (must not benull
)- Returns:
- the supplier (not
null
)
-
createResourceSupplier
public static Supplier<String> createResourceSupplier(String resource, ClassLoader classLoader, Supplier<String> fallback)
Create a supplier which loads the banner from a resource in the given class loader, falling back to the given fallback supplier on error.- Parameters:
resource
- the resource name (must not benull
)classLoader
- the class loader to load from (must not benull
)fallback
- the fallback supplier (must not benull
)- Returns:
- the supplier (not
null
)
-
createResourceSupplier
public static Supplier<String> createResourceSupplier(String resource, Supplier<String> fallback)
Create a supplier which loads the banner from a resource in the caller's class loader, falling back to the given fallback supplier on error.- Parameters:
resource
- the resource name (must not benull
)fallback
- the fallback supplier (must not benull
)- Returns:
- the supplier (not
null
)
-
-