Operation
Operations are the core of the library. They are used to wrap code blocks, and provide a unified way to log and trace them, with rich context.
Basic Usage
The most basic usage of an operation is to wrap a code block with a with
statement:
This will fire a log record with rich operation metadata, like duration, result, exception, thread name, etc. This operation can be formatted according to your needs (verbose log line, csv, JSON, etc.).
For reference on example formatters, refer to OplogCsvFormatter or VerboseOplgLineFormatter.
A complete example that will print the operation log record to the stdout, using the verbose formatter: