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
A formatter which prints a text banner ahead of the normal formatter header.
The text banner is acquired from a
Supplier which is passed in to the constructor.
Several utility methods are also present which allow easy creation of Supplier 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
ConstructorsConstructorDescriptionTextBannerFormatter(Supplier<String> bannerSupplier, ExtFormatter delegate) Construct a new instance. -
Method Summary
Modifier and TypeMethodDescriptioncreateFileSupplier(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.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.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.createStringSupplier(String string) Create a supplier which always returns the given 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.Get the empty supplier which always returns an empty string.Methods inherited from class org.jboss.logmanager.ExtFormatter.Delegating
format, formatMessage, getTail, isCallerCalculationRequiredMethods inherited from class org.jboss.logmanager.ExtFormatter
format, formatMessageLegacy, formatMessageNone, formatMessagePrintf, wrap
-
Constructor Details
-
TextBannerFormatter
Construct a new instance.- Parameters:
bannerSupplier- the supplier for the banner (must not benull)delegate- the delegate formatter (must not benull)
-
-
Method Details
-
getHead
- Overrides:
getHeadin classExtFormatter.Delegating
-
getEmptySupplier
Get the empty supplier which always returns an empty string.- Returns:
- the empty supplier (not
null)
-
createStringSupplier
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
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
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
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)
-