Packages

package flow

Ordering
  1. Alphabetic
Visibility
  1. Public
  2. Protected

Type Members

  1. trait FlowBehavior[B] extends AnyRef

    A type class that is used to provide a behavior to a logging flow.

    A type class that is used to provide a behavior to a logging flow.

    You can implement your own behavior and place it in scope for the code that you're using:

    private implicit def flowBehavior[B: ToArguments]: FlowBehavior[B] = new FlowBehavior[B] {
      override def createEntryStatement(source: FlowBehavior.Source): Option[Statement] = {
        Some(
          Statement().withMessage(s"${source.enclosing.value} entry")
        )
      }
    }

    You can use the createEntryStatement to start a timer and then complete it on exit/throwing, or use the flow as hooks into the tracing framework.

  2. trait FlowLogger extends SLF4JLoggerAPI[CorePredicate, FlowMethod] with UnderlyingMixin with MarkerMixin with EntryTransformMixin with EventBufferMixin with OnConditionMixin

    This trait implements a logger that is used for rendering entry/exit logging wrappers.

    This trait implements a logger that is used for rendering entry/exit logging wrappers.

    The FlowMethod implements the bulk of the logic here, and is intended to be used with a user-provided FlowBehavior that determines what statements and side effects happen on entry and exit.

    If logging is enabled, then the execution is wrapped to capture the result or execution, and then the result is returned or execution rethrown. If the logging level is not enabled or logging execution is denied by a filter, then execution of the block still proceeds but is not wrapped by a Try block.

    You should use Condition.never explicitly here to disable logging, as it will shortcut to a Noop implementation. Benchmarks show a noop flow takes 42ns to execute, 4.5ns if you remove sourcecode.Args from the method signature.

    import com.tersesystems.blindsight._
    import com.tersesystems.blindsight.flow._
    
    implicit def flowBehavior[B: ToArgument]: FlowBehavior[B] = new SimpleFlowBehavior
    val logger = LoggerFactory.getLogger
    val flowLogger: FlowLogger = logger.flow
    val resultIsThree: Int = flowLogger.trace(1 + 2)
  3. trait FlowMethod extends AnyRef

    This trait wraps an execution block, and applies a FlowBehavior to it on entry, exit, and exception.

    This trait wraps an execution block, and applies a FlowBehavior to it on entry, exit, and exception.

    Note that the return value must have a type class instance of ToArgument in scope, so that the logging statement can render it appropriately.

    You should use Condition.never explicitly here to disable logging, as it will shortcut to a Noop implementation. Benchmarks show a noop flow takes 42ns to execute, 4.5ns if you remove sourcecode.Args from the method signature.

  4. class SimpleFlowBehavior[B] extends FlowBehavior[B]

    A simple flow behavior that prints out the arguments and result, with the line number.

    A simple flow behavior that prints out the arguments and result, with the line number.

    B

    the type of the result.

  5. class XLoggerFlowBehavior[B] extends FlowBehavior[B]

    A flow behavior that implements the extended logger interface.

    A flow behavior that implements the extended logger interface.

    B

    the return type.

    See also

    https://github.com/qos-ch/slf4j/blob/master/slf4j-ext/src/main/java/org/slf4j/ext/XLogger.java

Value Members

  1. object FlowBehavior
  2. object FlowLogger
  3. object FlowMethod
  4. object XLoggerFlowBehavior

Ungrouped