Phosphor
|
#include <trace_config.h>
Public Member Functions | |
TraceConfig (BufferMode _buffer_mode, size_t _buffer_size) | |
TraceConfig (trace_buffer_factory _buffer_factory, size_t _buffer_size) | |
BufferMode | getBufferMode () const |
size_t | getBufferSize () const |
trace_buffer_factory | getBufferFactory () const |
TraceConfig & | setStoppedCallback (std::shared_ptr< TracingStoppedCallback > _tracing_stopped_callback) |
TracingStoppedCallback * | getStoppedCallback () const |
TraceConfig & | setStopTracingOnDestruct (bool _stop_tracing) |
bool | getStopTracingOnDestruct () const |
TraceConfig & | setCategories (const std::vector< std::string > &enabled, const std::vector< std::string > &disabled) |
const std::vector< std::string > & | getEnabledCategories () const |
const std::vector< std::string > & | getDisabledCategories () const |
StringPtr | toString () const |
Static Public Member Functions | |
static TraceConfig | fromString (const std::string &config) |
Static Protected Member Functions | |
static trace_buffer_factory | modeToFactory (BufferMode mode) |
Protected Attributes | |
BufferMode | buffer_mode = BufferMode::fixed |
size_t | buffer_size = 0 |
trace_buffer_factory | buffer_factory = nullptr |
std::shared_ptr< TracingStoppedCallback > | tracing_stopped_callback |
bool | stop_tracing = false |
std::vector< std::string > | enabled_categories |
std::vector< std::string > | disabled_categories |
The TraceConfig is used to configure a TraceLog for starting Trace when it is enabled.
The TraceConfig has two constructors with two different aims in mind
The first of these is specified by using the mode enumeration, the second is specified by passing in the TraceBufferFactory.
The second parameter to both of these is the size in bytes of the TraceBuffer.
All other arguments are optional and may be specified using chainable methods.
phosphor::TraceConfig::TraceConfig | ( | BufferMode | _buffer_mode, |
size_t | _buffer_size | ||
) |
Constructor used when using a builtin TraceBuffer type
_buffer_mode | Which buffer mode to use. Cannot be BufferMode::Custom. |
_buffer_size | Maximum size in bytes of the trace buffer. |
phosphor::TraceConfig::TraceConfig | ( | trace_buffer_factory | _buffer_factory, |
size_t | _buffer_size | ||
) |
Constructor used when supplying a custom TraceBuffer implementation
_buffer_factory | The trace buffer factory to be used. |
_buffer_size | Maximum size in bytes of the trace buffer. |
|
static |
Generate a TraceConfig from a config string (Usually set from an environment variable).
Example:
TraceConfig::fromString("buffer-mode:fixed,buffer-size:1024");
config | Config string to be used to generate the TraceConfig |
trace_buffer_factory phosphor::TraceConfig::getBufferFactory | ( | ) | const |
BufferMode phosphor::TraceConfig::getBufferMode | ( | ) | const |
size_t phosphor::TraceConfig::getBufferSize | ( | ) | const |
const std::vector< std::string > & phosphor::TraceConfig::getDisabledCategories | ( | ) | const |
const std::vector< std::string > & phosphor::TraceConfig::getEnabledCategories | ( | ) | const |
TracingStoppedCallback * phosphor::TraceConfig::getStoppedCallback | ( | ) | const |
bool phosphor::TraceConfig::getStopTracingOnDestruct | ( | ) | const |
|
staticprotected |
Get the trace buffer factory for the given mode.
Cannot be used for the custom mode
mode | The trace buffer mode to convert |
std::invalid | argument if given mode is invalid |
TraceConfig & phosphor::TraceConfig::setCategories | ( | const std::vector< std::string > & | enabled, |
const std::vector< std::string > & | disabled | ||
) |
Set the categories to enable/disable in this trace config
enabled | The categories to explicitly enable |
disabled | The categories to explicitly disable |
TraceConfig & phosphor::TraceConfig::setStoppedCallback | ( | std::shared_ptr< TracingStoppedCallback > | _tracing_stopped_callback | ) |
Set the tracing_stopped_callback to be invoked when tracing stops.
_tracing_stopped_callback | Callback to be used. Note this is passed as a shared_ptr due to it not being safe to copy Callbacks in the general case, as it may have been allocated with a different CRT than phosphor itself is linked against. |
TraceConfig & phosphor::TraceConfig::setStopTracingOnDestruct | ( | bool | _stop_tracing | ) |
Sets whether or not the tracing shutdown (and therefore callbacks) should be run when the TraceLog is destroyed. Defaults to false.
_stop_tracing | Stop tracing on shutdown |
StringPtr phosphor::TraceConfig::toString | ( | ) | const |
Converts a TraceConfig to a config string.
This can be used to convert the TraceConfig that a TraceLog is using to a human readable form.