OpenCPN Partial API docs
Loading...
Searching...
No Matches
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. More...
 
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.

Constructor & Destructor Documentation

◆ OcpnLog()

OcpnLog::OcpnLog ( const char *  path)

Create logger appending to given filename.

Definition at line 82 of file logger.cpp.

◆ ~OcpnLog()

OcpnLog::~OcpnLog ( )
virtual

Definition at line 86 of file logger.cpp.

Member Function Documentation

◆ DoLogRecord()

void OcpnLog::DoLogRecord ( wxLogLevel  level,
const wxString &  msg,
const wxLogRecordInfo &  info 
)
override

Definition at line 93 of file logger.cpp.

◆ Flush()

void OcpnLog::Flush ( )
override

Definition at line 88 of file logger.cpp.

◆ level2str()

std::string OcpnLog::level2str ( wxLogLevel  level)
static

Definition at line 67 of file logger.cpp.

◆ str2level()

wxLogLevel OcpnLog::str2level ( const char *  string)
static

Definition at line 72 of file logger.cpp.

Member Data Documentation

◆ log

std::ofstream OcpnLog::log
protected

Definition at line 80 of file logger.h.

◆ LOG_BADLEVEL

const wxLogLevel OcpnLog::LOG_BADLEVEL = wxLOG_Max + 1
static

Definition at line 64 of file logger.h.


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