AsyncFw 1.2
Async Framework is c++ runtime with timers, poll notifiers, sockets, coroutines, etc.
 
Loading...
Searching...
No Matches
AsyncFw::Log Class Reference

The Log class. More...

#include <AsyncFw/Log>

Inheritance diagram for AsyncFw::Log:
[legend]
Collaboration diagram for AsyncFw::Log:
[legend]

Public Types

using Message = LogStream::Message
 
using MessageType = LogStream::MessageType
 
using Color = LogStream::Color
 
- Public Types inherited from AsyncFw::Rrd
using Item = DataArray
 
using ItemList = DataArrayList
 
- Public Types inherited from AsyncFw::AbstractLog
using Message = LogStream::Message
 

Public Member Functions

 Log (int=0, const std::string &={})
 
void finality ()
 
void output (const Message &m) override
 
void setAutoSave (bool b)
 
Rrd::Item rrdItemFromMessage (const Message &m) const
 
Message messageFromRrdItem (const Rrd::Item &_v) const
 
Message readMessage (uint32_t index)
 
void writeMessage (uint32_t index, const Message &message)
 
void save () override
 
void append (uint8_t, const std::string &, const std::string &, const std::string &={})
 
void append (const Message &m)
 
- Public Member Functions inherited from AsyncFw::Rrd
template<typename T>
void setAverage (int _interval, T f, int _offset=0)
 
 Rrd (int size, int interval, int fillInterval, const std::string &name)
 
 Rrd (int size, int interval, int fillInterval)
 
 Rrd (int size, const std::string &name)
 
 Rrd (int size)
 
uint64_t read (DataArrayList *list, uint64_t from=0, uint32_t size=0, uint64_t *lastIndex=nullptr)
 
void setFillInterval (int interval)
 
uint32_t size ()
 
uint32_t count ()
 
Item readFromArray (uint32_t)
 
void writeToArray (uint32_t, const Item &)
 
void append (const Item &data, uint64_t index=0)
 
void save (const std::string &fn={})
 
void clear ()
 
uint64_t lastIndex ()
 
Threadthread ()
 
- Public Member Functions inherited from AsyncFw::AbstractLog
void append (uint8_t, const std::string &, const std::string &, const std::string &={})
 
void setExtendOut (bool b)
 
void setColorOut (bool b)
 
void setNotesOut (bool b)
 
void setHideDuplicates (bool b)
 
void setLevel (int i)
 
void setConsoleLevel (int i)
 
void setFilter (const std::vector< std::string > &f)
 

Static Public Member Functions

static Loginstance ()
 

Protected Attributes

int autoSave
 
int timerIdAutosave = -1
 
Threadthread_
 
- Protected Attributes inherited from AsyncFw::Rrd
Threadthread_
 
uint64_t last_
 
uint32_t dbSize
 
ItemList dataBase
 
uint32_t count_v
 
bool readOnly = false
 
- Protected Attributes inherited from AsyncFw::AbstractLog
uint8_t level = LogStream::Trace
 
uint8_t consoleLevel = LogStream::Trace
 
int queueLimit = 128
 
Threadthread_
 

Additional Inherited Members

- Public Attributes inherited from AsyncFw::Rrd
FunctionConnectorProtected< Rrd >::Connector<> updated
 
- Protected Member Functions inherited from AsyncFw::AbstractLog
void append (const Message &m)
 
void flush ()
 
void finality ()
 

Detailed Description

The Log class.

Example:

#include <AsyncFw/Version>
#include <AsyncFw/MainThread>
#include <AsyncFw/Log>
int main(int argc, char *argv[]) {
AsyncFw::Thread logThread {"LogThread"};
logThread.start();
logThread.invokeMethod([]() { AsyncFw::Instance<AsyncFw::Log>::create(1000, "log-file-name"); }, true);
AsyncFw::Log::instance()->setColorOut(true);
logNotice() << "Version:" << AsyncFw::Version::str();
logNotice() << "Git:" << AsyncFw::Version::git();
lsTrace() << "Trace";
lsDebug() << "Debug";
lsInfo() << "Info";
lsInfoRed() << "Info red";
lsInfoGreen() << "Info green";
lsInfoBlue() << "Info blue";
lsInfoMagenta() << "Info magenta";
lsInfoCyan() << "Info cyan";
lsNotice() << "Notice";
lsWarning() << "Warning";
lsError() << "Error";
logTrace() << "Trace";
logDebug() << "Debug";
logInfo() << "Info";
logNotice() << "Notice";
logWarning() << "Warning";
logError() << "Error";
logAlert() << "logAlert";
//logEmergency() << "Emergency"; // throw
AsyncFw::Thread::currentThread()->invokeMethod([]() { AsyncFw::MainThread::exit(); });
int ret = AsyncFw::MainThread::exec();
AsyncFw::Log::instance()->append({AsyncFw::LogStream::Info, "Log", "Application finished", ""});
return ret;
}

Member Function Documentation

◆ output()

void Log::output ( const Message & m)
overridevirtual

Reimplemented from AsyncFw::AbstractLog.

◆ save()

void AsyncFw::Log::save ( )
inlineoverridevirtual

Implements AsyncFw::AbstractLog.


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