Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | Private Attributes | List of all members
BufferLogger Class Reference

BufferLogger. More...

#include <ored/utilities/log.hpp>

+ Inheritance diagram for BufferLogger:
+ Collaboration diagram for BufferLogger:

Public Member Functions

 BufferLogger (unsigned minLevel=64)
 Constructor. More...
 
virtual ~BufferLogger ()
 Destructor. More...
 
virtual void log (unsigned, const std::string &) override
 The log callback. More...
 
bool hasNext ()
 Checks if Logger has new messages. More...
 
std::string next ()
 Retrieve new messages. More...
 
- Public Member Functions inherited from Logger
virtual ~Logger ()
 Destructor. More...
 
virtual void log (unsigned level, const std::string &s)=0
 The Log call back function. More...
 
const std::string & name ()
 Returns the Logger name. More...
 

Static Public Attributes

static const std::string name = "BufferLogger"
 the name "BufferLogger" More...
 

Private Attributes

std::queue< std::string > buffer_
 
unsigned minLevel_
 

Additional Inherited Members

- Protected Member Functions inherited from Logger
 Logger (const std::string &name)
 Constructor. More...
 

Detailed Description

BufferLogger.

This logger stores each log message in an internal buffer, it can then be probed for log messages at a later point. Log messages are always returned in a FIFO order.

Typical usage to display log messages would be

    while (bLogger.hasNext()) {
        MsgBox("Log Message", bLogger.next());
    }
See also
Log

Definition at line 228 of file log.hpp.

Constructor & Destructor Documentation

◆ BufferLogger()

BufferLogger ( unsigned  minLevel = 64)

Constructor.

Definition at line 233 of file log.hpp.

233: Logger(name), minLevel_(minLevel) {}
static const std::string name
the name "BufferLogger"
Definition: log.hpp:231
unsigned minLevel_
Definition: log.hpp:254
Logger(const std::string &name)
Constructor.
Definition: log.hpp:152

◆ ~BufferLogger()

virtual ~BufferLogger ( )
virtual

Destructor.

Definition at line 235 of file log.hpp.

235{}

Member Function Documentation

◆ log()

void log ( unsigned  level,
const std::string &  s 
)
overridevirtual

The log callback.

Implements Logger.

Definition at line 68 of file log.cpp.

68 {
69 if (level <= minLevel_)
70 buffer_.push(s);
71}
std::queue< std::string > buffer_
Definition: log.hpp:253

◆ hasNext()

bool hasNext ( )

Checks if Logger has new messages.

Returns
True if this BufferLogger has any new log messages

Definition at line 73 of file log.cpp.

73{ return !buffer_.empty(); }

◆ next()

string next ( )

Retrieve new messages.

Retrieve the next new message from the buffer, this will throw if the buffer is empty. Messages are returned in a FIFO order. Messages are deleted from the buffer once returned.

Returns
The next message

Definition at line 75 of file log.cpp.

75 {
76 QL_REQUIRE(!buffer_.empty(), "Log Buffer is empty");
77 string s = buffer_.front();
78 buffer_.pop();
79 return s;
80}

Member Data Documentation

◆ name

const string name = "BufferLogger"
static

the name "BufferLogger"

Definition at line 231 of file log.hpp.

◆ buffer_

std::queue<std::string> buffer_
private

Definition at line 253 of file log.hpp.

◆ minLevel_

unsigned minLevel_
private

Definition at line 254 of file log.hpp.