Class InstantPatternThreadLocalCachedFormatter
java.lang.Object
org.apache.logging.log4j.core.util.internal.instant.InstantPatternThreadLocalCachedFormatter
- All Implemented Interfaces:
InstantFormatter,InstantPatternFormatter
final class InstantPatternThreadLocalCachedFormatter
extends Object
implements InstantPatternFormatter
An
InstantFormatter wrapper caching the last formatted output in a ThreadLocal and trying to reuse it.- Since:
- 2.25.0
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.logging.log4j.core.util.internal.instant.InstantPatternFormatter
InstantPatternFormatter.Builder -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ThreadLocal<Object[]> private final InstantPatternFormatterprivate final ChronoUnitFields inherited from interface org.apache.logging.log4j.core.util.internal.instant.InstantPatternFormatter
LEGACY_FORMATTERS_ENABLED -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateInstantPatternThreadLocalCachedFormatter(InstantPatternFormatter formatter, Function<Instant, Long> epochInstantExtractor, ChronoUnit precision) -
Method Summary
Modifier and TypeMethodDescriptionprivate static Object[]private static ChronoUniteffectivePrecision(InstantFormatter formatter, ChronoUnit cachePrecision) voidformatTo(StringBuilder buffer, Instant instant) (package private) static InstantPatternThreadLocalCachedFormatterofMilliPrecision(InstantPatternFormatter formatter) (package private) static InstantPatternThreadLocalCachedFormatterofSecondPrecision(InstantPatternFormatter formatter) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.logging.log4j.core.util.internal.instant.InstantFormatter
format
-
Field Details
-
formatter
-
epochInstantExtractor
-
epochInstantAndBufferRef
-
precision
-
-
Constructor Details
-
InstantPatternThreadLocalCachedFormatter
private InstantPatternThreadLocalCachedFormatter(InstantPatternFormatter formatter, Function<Instant, Long> epochInstantExtractor, ChronoUnit precision)
-
-
Method Details
-
createEpochInstantAndBuffer
-
ofMilliPrecision
-
ofSecondPrecision
static InstantPatternThreadLocalCachedFormatter ofSecondPrecision(InstantPatternFormatter formatter) -
effectivePrecision
-
getPrecision
- Specified by:
getPrecisionin interfaceInstantFormatter- Returns:
- the time precision of the formatted output
-
formatTo
- Specified by:
formatToin interfaceInstantFormatter
-
getPattern
- Specified by:
getPatternin interfaceInstantPatternFormatter
-
getLocale
- Specified by:
getLocalein interfaceInstantPatternFormatter
-
getTimeZone
- Specified by:
getTimeZonein interfaceInstantPatternFormatter
-