public abstract class AbstractFormattedTimestampJsonProvider<Event extends DeferredProcessingAware,FieldNames extends LogstashCommonFieldNames> extends AbstractFieldJsonProvider<Event> implements FieldNamesAware<FieldNames>
DateTimeFormatter
patternModifier and Type | Field and Description |
---|---|
static String |
DEFAULT_TIMEZONE_KEYWORD
Keyword used by
setTimeZone(String) to denote the system default time zone. |
static String |
FIELD_TIMESTAMP |
static String |
UNIX_TIMESTAMP_AS_NUMBER
Setting the
pattern as this value will make it so that the timestamp
is written as a number value of the milliseconds since unix epoch. |
static String |
UNIX_TIMESTAMP_AS_STRING
Setting the
pattern as this value will make it so that the timestamp
is written as a string value representing the number of milliseconds since unix epoch |
context
Constructor and Description |
---|
AbstractFormattedTimestampJsonProvider() |
Modifier and Type | Method and Description |
---|---|
protected String |
getFormattedTimestamp(Event event) |
String |
getPattern() |
protected abstract long |
getTimestampAsMillis(Event event) |
String |
getTimeZone()
Get the time zone used to write the timestamp.
|
void |
setFieldNames(FieldNames fieldNames) |
void |
setPattern(String pattern) |
void |
setTimeZone(String timeZone)
Set the timezone for which to write the timestamp.
|
void |
writeTo(JsonGenerator generator,
Event event)
Writes information about the event, to the given generator.
|
getFieldName, setFieldName
isStarted, prepareForDeferredProcessing, start, stop
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, getDeclaredOrigin, getStatusManager, setContext
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, setContext
public static final String FIELD_TIMESTAMP
public static final String UNIX_TIMESTAMP_AS_NUMBER
pattern
as this value will make it so that the timestamp
is written as a number value of the milliseconds since unix epoch.public static final String UNIX_TIMESTAMP_AS_STRING
pattern
as this value will make it so that the timestamp
is written as a string value representing the number of milliseconds since unix epochpublic static final String DEFAULT_TIMEZONE_KEYWORD
setTimeZone(String)
to denote the system default time zone.public AbstractFormattedTimestampJsonProvider()
public void setFieldNames(FieldNames fieldNames)
setFieldNames
in interface FieldNamesAware<FieldNames extends LogstashCommonFieldNames>
public void writeTo(JsonGenerator generator, Event event) throws IOException
JsonProvider
When called, the generator is assumed to be within a JSON object context (i.e. this provider should write fields and their values to the generator). Upon return, the generator should be within the same JSON object context.
writeTo
in interface JsonProvider<Event extends DeferredProcessingAware>
generator
- the JsonGenerator
to produce JSON contentevent
- the event to convert into JSONIOException
- if an I/O error occursprotected abstract long getTimestampAsMillis(Event event)
public String getPattern()
public void setPattern(String pattern)
public String getTimeZone()
public void setTimeZone(String timeZone)
The value of the timeZone
can be any string accepted by java's TimeZone.getTimeZone(String)
method.
For example "America/Los_Angeles" or "GMT+10".
Use a blank string, null
or the value "[DEFAULT]" to use the default TimeZone of the system.
timeZone
- the textual representation of the desired time zoneIllegalArgumentException
- if the input string is not a valid TimeZone representationCopyright © 2013–2021. All rights reserved.