org.scalawag.timber.backend.receiver.formatter
ProgrammableEntryFormatter
Companion object ProgrammableEntryFormatter
class ProgrammableEntryFormatter extends EntryFormatter
Formats entries using the specified metadata providers to create a header. The metadata providers can
be specified using the mini-DSL on the entry object:
threadName- the name of the thread that created the entrytimestamp- the timestamp at which the entry was createdlevel- the level at which the entry was created (if available)loggingClass- the class from which the log method was called (if available)loggingMethod- the method from which the log method was called (if available)sourceLocation- the location in source (file name and line number) from which the log method was called (if available)tags- the tags associated with the entryloggerAttributes- the logger attributes associated with the entrythreadAttributes- the thread attributes associated with the entryloggerAttribute(name)- the logger attribute with the specified name associated with the entry (if available)threadAttribute(name)- the thread attribute with the specified name associated with the entry (if available)
new ProgrammableEntryFormatter(Seq(entry.threadName,entry.loggingClass))
You can also specify Strings to be included literally.
new ProgrammableEntryFormatter(Seq("literal",entry.loggingClass))
In addition to the providers above, you can specify some modifiers to tweak them before their inclusion:
formattedWith- allows you to choose how the metadata is formatted, must match the type of the metadatamap- allows you to apply an arbitrary mapping function to the metadata before inclusionwithout- allows you to remove keys from a map before inclusion (e.g., if you already included on of the keys specifically)
If you don't specify a formatter, the toString method of the object will be used. There are some built-in
formatters for timestamps and
levels that you can use. There are also some built-in
formatters for any Iterables that may be more appealing than the default toString implementation.
Commas- formats Iterables as strings with commas separating the itemsSpaces- formats Iterables as strings with spaces separating the itemsDelimiter(str)- formats Iterables as strings with the specified delimiter separating the itemsCommasAndEquals- formats Maps as equals-separated pairs separated by commas (e.g.,k1=v1,k2=v2)
entry.timestamp formattedWith HumanReadableTimestampFormatter entry.timestamp formattedWith SimpleDateFormatTimestampFormatter("yyyy/MM/dd") entry.threadName map { name => name.length } entry.loggerAttributes without "name" formattedWith CommasAndEquals
For the metadata that may not be present (indicated with "if available" above), you can specify a fallback to use when it's absent with orElse.
You can't use orElse after a metadata provider that will definitely return something.
entry.loggingClass orElse entry.loggerAttribute("name") orElse "unknown"
With certain combinations of modifiers, you may have to include parentheses if the scala compiler can't figure out the operator precedence. You can also specify the modifiers without utilizing the infix call style, if you prefer.
- Alphabetic
- By Inheritance
- ProgrammableEntryFormatter
- EntryFormatter
- Formatter
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Instance Constructors
- new ProgrammableEntryFormatter(metadataProviders: Seq[MetadataProvider], delimiter: String = "|", continuationHeader: ProgrammableEntryFormatter.ContinuationHeader.Value = ProgrammableEntryFormatter.ContinuationHeader.NONE, firstLinePrefix: String = "+", continuationPrefix: String = " ", missingValueString: String = "")
- metadataProviders
a list of metadata providers to be used to create headers to be included with the message
- delimiter
the string that separates metadata headers from each other and from the message lines
- continuationHeader
determines what header is included on lines after the first
- firstLinePrefix
determines the prefix for the first line of output for an entry
- continuationPrefix
determines the prefix for the remaining lines of an entry
- missingValueString
determines the string to use for optional metadata providers that return no content
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- val continuationHeader: ProgrammableEntryFormatter.ContinuationHeader.Value
- val continuationPrefix: String
- val delimiter: String
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- val firstLinePrefix: String
- def format(entry: Entry): String
- Definition Classes
- ProgrammableEntryFormatter → Formatter
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- val metadataProviders: Seq[MetadataProvider]
- val missingValueString: String
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()