This class represents an argument to a logging statement.
This class represents an argument to a logging statement.
Normally this is used in a ToArgument type class instance, and you should not have to use it in a logging statement directly.
Note that an exception is **not** a valid argument, and exceptions are
handled explicitly as java.lang.Throwable
in the APIs.
This trait allows a type that has a ToArgument type class instance to render as an Argument.
This trait allows a type that has a ToArgument type class instance to render as an Argument.
This is especially useful in the SLF4J API, which does not take a ToMarkers instance.
import ArgumentEnrichment._ val argument: Argument = myInstance.asArgument
Resolves a com.tersesystems.blindsight.AST.BObject to an Argument.
Resolves a com.tersesystems.blindsight.AST.BObject to an Argument.
val argument: Argument = ArgumentResolver(bobj("foo" -> "bar"))
This is a service interface trait, which should be implemented the service loader pattern.
This is the representation of arguments in an SLF4J logging statement.
This is the representation of arguments in an SLF4J logging statement. It is used to
prevent the use of varadic arguments in the SLF4J API, which is a problem for type safety
and also causes problems with : _*
type ascryption and confused IDEs.
Arguments present as an immutable API, which can be composed together using +
and
++
for sequences.
val argsA: Arguments = Arguments("a", 1) val argsPlus: Arguments = argsA + true
A DSL to produce valid AST of values.
A DSL to produce valid AST of values.
This is "inspired" by JSON4S code.
import com.tersesystems.blindsight.AST._ import com.tersesystems.blindsight.DSL._ ("name", "joe") ~ ("age", 15) == BObject(BField("name",BString("joe")) :: BField("age",BInt(15)) :: Nil)
An underlying statement immediately before being sent to SLF4J.
An event buffer contains events that were about to be logged into SLF4J.
An event buffer contains events that were about to be logged into SLF4J.
Event buffers are very useful for testing and for keeping diagnostic log entries for a brief period of time, but may not have 1:1 equivalence with what ends up in the logs.
The Blindsight logger trait.
The logger factory is a trait that returns a Blindsight logger, using a type class instance of LoggerResolver.
The logger resolver is a type class that can return an SLF4J logger from the instance.
The logger resolver is a type class that can return an SLF4J logger from the instance.
It should be used with loggerFactory.getLogger
.
It is useful when you want a logger based on something other than a class or string.
This class represents the markers that are associated with the logging statement.
This class represents the markers that are associated with the logging statement.
Normally this is used in a ToArgument type class instance, and you should not have to use it in a logging statement directly.
Markers represents all added org.slf4j.Marker
instances together in an immutable Set,
and only at the end wrapped into a marker with markers.marker
. This generated marker
uses the internal hashcode and contains all the markers in the set as direct children.
val markers: Markers = Markers(marker)
Markers does not directly use the SLF4J marker API, as directly mutating markers together as "child references" so that only one marker is available is generally unsafe.
This trait allows a type that has a ToMarkers
type class instance to render as a Markers
.
This trait allows a type that has a ToMarkers
type class instance to render as a Markers
.
This is especially useful in the SLF4J API, which does not take a ToMarkers
instance.
import MarkersEnrichment._ val markers: Markers = myInstance.asMarkers
Resolves a com.tersesystems.blindsight.AST.BObject to Markers.
Resolves a com.tersesystems.blindsight.AST.BObject to Markers.
val markers: Markers = MarkersResolver(bobj("foo" -> "bar"))
This is a service interface trait, which should be implemented the service loader pattern.
This class represents the message portion of a logging statement.
This class represents the message portion of a logging statement.
A Message
is immutable, and so composing a message is a concatenation
of Message + Message
.
There is an implicit conversion of string to message, but for general purpose, ToMessage should be used to convert objects.
val message = Message("foo") logger.info(message)
A statement represents a total logging statement.
A statement represents a total logging statement. This is most useful for semantic logging, which converts objects to Statement, but is generally helpful in packaging as well.
This is a type class used to convert given types to Argument.
This is a type class used to convert given types to Argument.
case class Person(name: String, age: Int) implicit val personToArgument: ToArgument[Person] = ToArgument { person => import net.logstash.logback.argument.StructuredArguments._ new Argument(keyValue("person", person.name)) }
the type to convert to Arguments
This is a type class used to convert given types to Markers.
This is a type class used to convert given types to Markers.
Markers are very useful for structured logging, because they can be converted into key/value pairs without altering the structure of a message or keeping the ordering in arguments (especially since an exception must be at the end of the tail).
The API does not define type class instances in this layer, but the logstash package provides many useful mappings to Markers.
case class Person(name: String, age: Int) implicit val personToMarkers: ToMarkers[Person] = ToMarkers { person => val personObj = bobj("name" -> person.name) Markers(personObj) }
the type to convert to Markers
This is a type class used to convert given types to Message
.
This is a type class used to convert given types to Message
.
case class Person(name: String, age: Int) implicit val personToMessage: ToMessage[Foo] = ToMessage { person => new Message(person.name) }
the type to convert to Message
Type class for mapping to a Statement
.
Type class for mapping to a Statement
.
case class Person(name: String, age: Int) implicit val personToStatement: ToStatement[Person] = ToStatement { person => Statement(markers = Markers.empty, message = Message("Person({}, {})"), arguments = Arguments(person.name) + person.age, throwable = None) }
the type to convert to a Statement
The abstract syntax tree.
The abstract syntax tree. This is used to represent valid structured data, without requiring it to be in a particular format, i.e. JSON, logfmt, or XML. Instead, either MarkersResolver or ArgumentResolver is used to convert from AST to Markers or Argument, respectively.
A tree is typically constructed by using the DSL.
import com.tersesystems.blindsight.AST._ import com.tersesystems.blindsight.DSL._ val o: BObject = bobj("foo" -> "bar")
(Since version 1.0.0) This is a typo of bobj (short for bobject)