Class Log

Nested Relationships

Nested Types

Class Documentation

class Log

Logging utilities. Logging is accessed through the three macros above, and configuration on the log output can be achieved through static methods on the class. Logging at various levels can be disabled dynamically (through the Verbosity level) or statically (through the LOG_NO_[VERB] macros) for maximum performance.

Public Types

enum Kind

Types of log entry.

  • Error: Maximum priority. Can only be disabled statically through LOG_NO_ERROR.

  • Warning: Medium priority. Can be disabled statically and dynamically.

  • Info: Low priority. Useful for debugging. Disabled by default on release branches.

Values:

enumerator Error
enumerator Warning
enumerator Info

Public Static Functions

static RTPS_DllAPI void RegisterConsumer (std::unique_ptr< LogConsumer > &&consumer)

Registers an user defined consumer to route log output. There is a default stdout consumer active as default.

Parameters:

consumer – r-value to a consumer unique_ptr. It will be invalidated after the call.

static RTPS_DllAPI void ClearConsumers ()

Removes all registered consumers, including the default stdout.

static RTPS_DllAPI void ReportFilenames (bool)

Enables the reporting of filenames in log entries. Disabled by default.

static RTPS_DllAPI void ReportFunctions (bool)

Enables the reporting of function names in log entries. Enabled by default when supported.

static RTPS_DllAPI void SetVerbosity (Log::Kind)

Sets the verbosity level, allowing for messages equal or under that priority to be logged.

static RTPS_DllAPI Log::Kind GetVerbosity ()

Returns the current verbosity level.

static RTPS_DllAPI void SetCategoryFilter (const std::regex &)

Sets a filter that will pattern-match against log categories, dropping any unmatched categories.

static RTPS_DllAPI void SetFilenameFilter (const std::regex &)

Sets a filter that will pattern-match against filenames, dropping any unmatched categories.

static RTPS_DllAPI void SetErrorStringFilter (const std::regex &)

Sets a filter that will pattern-match against the provided error string, dropping any unmatched categories.

static RTPS_DllAPI void SetThreadConfig (const rtps::ThreadSettings &)

Sets thread configuration for the logging thread.

static RTPS_DllAPI void Reset ()

Returns the logging engine to configuration defaults.

static RTPS_DllAPI void Flush ()

Waits until all info logged up to the call time is consumed.

static RTPS_DllAPI void KillThread ()

Stops the logging thread. It will re-launch on the next call to a successful log macro.

static RTPS_DllAPI void QueueLog (const std::string &message, const Log::Context &, Log::Kind)

Not recommended to call this method directly! Use the following macros:

  • EPROSIMA_LOG_INFO(cat, msg);

  • EPROSIMA_LOG_WARNING(cat, msg);

  • EPROSIMA_LOG_ERROR(cat, msg);

Todo:

this method takes 2 mutexes (same mutex) internally. This is a very high sensible point of the code and it should be refactored to be as efficient as possible.

struct Context

Public Members

const char *filename
int line
const char *function
const char *category
struct Entry

Public Members

std::string message
Log::Context context
Log::Kind kind
std::string timestamp