Class Log

Nested Relationships

Nested Types

Class Documentation

class Log

Public Types

enum class Tier : uint32_t

A computer-friendly ranking of how serious the log entry is.

Values:

enumerator Uninitialized

This is a sentinel value that should not generally be used.

enumerator Info

An expected occurrence took place.

enumerator Warning

An unexpected, problematic occurrence took place, but it can be recovered from. Human attention is recommended but not necessary.

enumerator Error

A problem happened, and humans should be alerted.

Public Functions

Log(std::function<rmf_traffic::Time()> clock = nullptr)

Construct a log.

Parameters:

clock[in] Specify a clock for this log to use. If nullptr is given, then std::chrono::system_clock::now() will be used.

void info(std::string text)

Add an informational entry to the log.

void warn(std::string text)

Add a warning to the log.

void error(std::string text)

Add an error to the log.

void push(Tier tier, std::string text)

Push an entry of the specified severity.

void insert(Log::Entry entry)

Insert an arbitrary entry into the log.

View view() const

Get a View of the current state of this log. Any new entries that are added after calling this function will not be visible to the View that is returned.

class Entry

A single entry within the log.

Public Functions

Tier tier() const

What was the tier of this entry.

uint32_t seq() const

Sequence number for this log entry. This increments once for each new log entry, until overflowing and wrapping around to 0.

rmf_traffic::Time time() const

What was the timestamp of this entry.

const std::string &text() const

What was the text of this entry.

class Reader

A Reader that can iterate through the Views of Logs. The Reader will keep track of which Entries have already been viewed, so every Entry read by a single Reader instance is unique.

Public Functions

Reader()

Construct a Reader.

Iterable read(const View &view)

Create an object that can iterate through the entries of a View. Any entries that have been read by this Reader in the past will be skipped. This can be used in a range-based for loop, e.g.:

for (const auto& entry : reader.read(view))
{
  std::cout << entry.text() << std::endl;
}
class Iterable

Public Types

using const_iterator = iterator

Public Functions

iterator begin() const

Get the beginning iterator of the read.

iterator end() const

Get the ending iterator of the read.

class iterator

Public Functions

const Entry &operator*() const

Dereference operator.

const Entry *operator->() const

Drill-down operator.

iterator &operator++()

Pre-increment operator: ++it

Note

This is more efficient than the post-increment operator.

Warning

It is undefined behavior to perform this operation on an iterator that is equal to Log::Reader::Iterable::end().

Returns:

a reference to the iterator itself

iterator operator++(int)

Post-increment operator: it++

Warning

It is undefined behavior to perform this operation on an iterator that is equal to Log::Reader::Iterable::end().

Returns:

a copy of the iterator before it was incremented.

bool operator==(const iterator &other) const

Equality comparison operator.

bool operator!=(const iterator &other) const

Inequality comparison operator.

class View

A snapshot view of the log’s contents. This is thread-safe to read even while new entries are being added to the log, but those new entries will not be seen by this View. You must retrieve a new View to see new entries.