OpenCPN Partial API docs
OcpnLog Class Reference

Logging interface. More...

#include <logger.h>

Inheritance diagram for OcpnLog:

Public Member Functions

 OcpnLog (const char *path)
 Create logger appending to given filename.
 
void Flush () override
 
void DoLogRecord (wxLogLevel level, const wxString &msg, const wxLogRecordInfo &info) override
 

Static Public Member Functions

static wxLogLevel str2level (const char *string)
 
static std::string level2str (wxLogLevel level)
 

Static Public Attributes

static const wxLogLevel LOG_BADLEVEL = wxLOG_Max + 1
 

Protected Attributes

std::ofstream log
 

Detailed Description

Logging interface.

The OcpnLog acts as the active wxLog target: it formats and prints log messages, overriding the default setup.

The Logger acts as a frontend to the wxLog logging providing C-style macros used like

LOG_INFO("Broken: %s", why);

Here is also C++ ostream log macros used like

INFO_LOG << "Broken: " << why;

These macros are very fast when logging is disabled for actual level, faster then the original wxLogMessage() and friends. They do not respect wxLog's component levels and trace masks, logging anything with a level <= wxLog::GetLogLevel(). Customized logger class appending to a file providing:

  • Millisecond timestamps
  • Consistent tagging WARNING, ERROR, MESSAGE etc.
  • Filename:line info.

Definition at line 62 of file logger.h.


The documentation for this class was generated from the following files: