A type class that is used to provide a behavior to a logging flow.
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)
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.
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.
the type of the result.
A flow behavior that implements the extended logger interface.
A flow behavior that implements the extended logger interface.
the return type.
https://github.com/qos-ch/slf4j/blob/master/slf4j-ext/src/main/java/org/slf4j/ext/XLogger.java
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:
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.