libASPL
|
#include <aspl/Tracer.hpp>
Classes | |
struct | Flags |
Operation flags. More... | |
struct | Operation |
Operation info. More... | |
Public Types | |
enum class | Mode { Noop , Stderr , Syslog , Custom } |
Tracing mode. More... | |
enum class | Style { Hierarchical , Flat } |
Tracing style. More... | |
Public Member Functions | |
Tracer (Mode mode=Mode::Syslog, Style style=Style::Hierarchical) | |
Initialize tracer. Mode defines where to send messages. Style defines how to format messages. | |
Tracer (const Tracer &)=delete | |
Tracer & | operator= (const Tracer &)=delete |
virtual void | OperationBegin (const Operation &operation) |
Called when an operations starts. Default implementation formats arguments and calls Print(). | |
virtual void | Message (const char *format,...) __attribute__((format(printf |
Called to print message to log. Default implementation formats arguments and calls Print(). | |
virtual void virtual void | OperationEnd (const Operation &operation, OSStatus status) |
Called when an operations completes. Zero status indicates operation success. Default implementation formats arguments and calls Print(). | |
Protected Member Functions | |
virtual std::string | FormatOperationBegin (const Operation &operation, UInt32 depth) |
Format operation begin message into string. Called by default implementation of OperationBegin(). | |
virtual std::string | FormatMessage (const char *message, UInt32 depth) |
Format message into string. Called by default implementation of Message(). | |
virtual std::string | FormatOperationEnd (const Operation &operation, OSStatus status, UInt32 depth) |
Format operation end message into string. Called by default implementation of OperationEnd(). | |
virtual void | Print (const char *message) |
Print message somewhere. Default implementation sends message to syslog if mode is Mode::Syslog, or does nothing if mode is Mode::Noop. | |
virtual bool | ShouldIgnore (const Operation &operation) |
Check whether the operation should be excluded from tracing. If this method returns true, the operation itself, as well as all nested operations, are not printed. Default implementation always returns false. | |
Operation tracer.
All objects use tracer to report operations issued by HAL. By default, tracer sends messages to syslog with "[aspl]" prefix.
Tracer maintains per-thread operations depth counter. Nested operations are automatically indented.
If you want to change formatting, you can use one of the predefined styles or override FormatXXX() methods.
If you want to change tracer output, you can use one of the predefined modes or override Print() method.
If you want to exclude some operations from trace, you can override ShouldIgnore() method.
Definition at line 34 of file Tracer.hpp.
|
strong |
Tracing mode.
Definition at line 38 of file Tracer.hpp.
|
strong |
Tracing style.
Enumerator | |
---|---|
Hierarchical | Indent nested operations. |
Flat | No indentation. |
Definition at line 58 of file Tracer.hpp.
|
explicit |
Initialize tracer. Mode defines where to send messages. Style defines how to format messages.
|
protectedvirtual |
Format message into string. Called by default implementation of Message().
|
protectedvirtual |
Format operation begin message into string. Called by default implementation of OperationBegin().
|
protectedvirtual |
Format operation end message into string. Called by default implementation of OperationEnd().
Called to print message to log. Default implementation formats arguments and calls Print().
Called when an operations starts. Default implementation formats arguments and calls Print().
|
virtual |
Called when an operations completes. Zero status indicates operation success. Default implementation formats arguments and calls Print().
Print message somewhere. Default implementation sends message to syslog if mode is Mode::Syslog, or does nothing if mode is Mode::Noop.
Check whether the operation should be excluded from tracing. If this method returns true, the operation itself, as well as all nested operations, are not printed. Default implementation always returns false.