PeriDyno 1.0.0
Loading...
Searching...
No Matches
dyno::Log Class Reference

#include <Log.h>

Classes

struct  Message
 

Public Types

enum  MessageType {
  DebugInfo , Info , Warning , Error ,
  User
}
 

Static Public Member Functions

static Loginstance ()
 
static void sendMessage (MessageType type, const std::string &text)
 Add a new message to log.
 
static void setUserReceiver (void(*userFunc)(const Message &))
 Set user function to receive newly sent messages to logger.
 
static void setLevel (MessageType level)
 Set minimum level of message to be logged to file.
 
static void setOutput (const std::string &filename)
 Open file where to log the messages.
 
static const std::string & getOutput ()
 Get the filename of log.
 

Private Member Functions

 Log ()
 
 ~Log ()
 
void outputThread ()
 
void writeMessage (MessageType level, const char *format,...)
 

Private Attributes

bool mRunning
 
std::mutex mtx
 
std::thread mThread
 
std::condition_variable mCondition
 

Static Private Attributes

static std::atomic< Log * > sLogInstance = nullptr
 
static std::queue< MessagesMessageQueue
 
static MessageType sLogLevel = Log::DebugInfo
 
static std::string sOutputFile
 
static std::ofstream sOutputStream
 
static void(* receiver )(const Message &) = nullptr
 

Detailed Description

Definition at line 42 of file Log.h.

Member Enumeration Documentation

◆ MessageType

Enumerator
DebugInfo 

Message with some debug information.

Info 

Information to user.

Warning 

Warning information.

Error 

Error information while executing something.

User 

User specific message.

Definition at line 45 of file Log.h.

Constructor & Destructor Documentation

◆ Log()

dyno::Log::Log ( )
private

Definition at line 103 of file Log.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ~Log()

dyno::Log::~Log ( )
private

Definition at line 109 of file Log.cpp.

Member Function Documentation

◆ getOutput()

const std::string & dyno::Log::getOutput ( )
static

Get the filename of log.

Definition at line 81 of file Log.cpp.

◆ instance()

Log * dyno::Log::instance ( )
static

Definition at line 86 of file Log.cpp.

Here is the call graph for this function:

◆ outputThread()

void dyno::Log::outputThread ( )
private

Definition at line 120 of file Log.cpp.

Here is the caller graph for this function:

◆ sendMessage()

void dyno::Log::sendMessage ( MessageType type,
const std::string & text )
static

Add a new message to log.

Parameters
typeType of the new message.
textMessage.
Remarks
Message is directly passes to user receiver if one is set.

Definition at line 41 of file Log.cpp.

Here is the caller graph for this function:

◆ setLevel()

void dyno::Log::setLevel ( MessageType level)
static

Set minimum level of message to be logged to file.

Definition at line 62 of file Log.cpp.

◆ setOutput()

void dyno::Log::setOutput ( const std::string & filename)
static

Open file where to log the messages.

Definition at line 67 of file Log.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setUserReceiver()

void dyno::Log::setUserReceiver ( void(* userFunc )(const Message &))
static

Set user function to receive newly sent messages to logger.

Definition at line 57 of file Log.cpp.

Here is the caller graph for this function:

◆ writeMessage()

void dyno::Log::writeMessage ( MessageType level,
const char * format,
... )
private

Definition at line 24 of file Log.cpp.

Member Data Documentation

◆ mCondition

std::condition_variable dyno::Log::mCondition
private

Definition at line 106 of file Log.h.

◆ mRunning

bool dyno::Log::mRunning
private

Definition at line 102 of file Log.h.

◆ mThread

std::thread dyno::Log::mThread
private

Definition at line 105 of file Log.h.

◆ mtx

std::mutex dyno::Log::mtx
private

Definition at line 104 of file Log.h.

◆ receiver

void(* dyno::Log::receiver)(const Message &) = nullptr
staticprivate

Definition at line 114 of file Log.h.

◆ sLogInstance

std::atomic< Log * > dyno::Log::sLogInstance = nullptr
staticprivate

Definition at line 108 of file Log.h.

◆ sLogLevel

Log::MessageType dyno::Log::sLogLevel = Log::DebugInfo
staticprivate

Definition at line 111 of file Log.h.

◆ sMessageQueue

std::queue< Log::Message > dyno::Log::sMessageQueue
staticprivate

Definition at line 110 of file Log.h.

◆ sOutputFile

std::string dyno::Log::sOutputFile
staticprivate

Definition at line 112 of file Log.h.

◆ sOutputStream

std::ofstream dyno::Log::sOutputStream
staticprivate

Definition at line 113 of file Log.h.


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