#include <LOG.hxx>
- Examples
- tests/util/MessageQueue.cxx.
Definition at line 32 of file LOG.hxx.
◆ MAX_LOG_SIZE_BYTES
◆ LOG()
Create a Logger.
Definition at line 12 of file LOG.cxx.
◆ ~LOG()
Destroy a Logger.
Definition at line 14 of file LOG.cxx.
24 __android_log_print(ANDROID_LOG_INFO,
"Cytopia",
"%s", message.c_str());
26 std::cout << message << std::endl;
◆ getTimeStamp()
Gets formatted TimeStamp.
- Returns
- std::string containing current TimeStamp
Definition at line 41 of file LOG.cxx.
43 std::time_t now = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
45 std::strftime(buf,
sizeof(buf),
"%b %d %H:%M:%S", std::localtime(&now));
◆ operator<<()
template<class Object >
LOG & LOG::operator<< |
( |
const Object & |
msg | ) |
|
Log a message.
- Template Parameters
-
msg | the streamable message type |
Definition at line 2 of file LOG.inl.hxx.
◆ writeErrorLog()
void LOG::writeErrorLog |
( |
const std::string & |
errorMessage | ) |
const |
|
private |
Write log message to error.log file.
If the log file exceeds MAX_LOG_SIZE_BYTES, logs will be cut in half
- Parameters
-
errorMessage | to write to error logfile |
Definition at line 49 of file LOG.cxx.
55 std::fstream fs(errfname, std::fstream::out | std::fstream::app);
60 fs << errorMessage << std::endl;
63 fs.seekp(0, std::fstream::end);
64 std::streampos Size = fs.tellp();
65 if (Size > MAX_LOG_SIZE_BYTES::value)
68 std::fstream fsToRotate(errfname, std::fstream::in | std::fstream::out);
71 std::streampos Cut = 0;
72 while (Size - Cut > MAX_LOG_SIZE_BYTES::value / 2 && std::getline(fsToRotate, line))
73 Cut += line.size() + 1;
74 stringstream truncatedstream;
75 truncatedstream << fsToRotate.rdbuf();
77 fsToRotate.open(
fs::getBasePath() +
string{
"error.log"}, std::fstream::trunc | std::fstream::out);
78 fsToRotate << truncatedstream.str();
◆ LOG_PREFIX
constexpr const char* LOG::LOG_PREFIX[] |
|
staticconstexprprivate |
Initial value:= {
" - [INFO] - ", " - [DEBUG] - ", " - [WARNING] - ", " - [ERROR] - ", " - [FATAL] - ",
}
Definition at line 44 of file LOG.hxx.
◆ LOG_PREFIX_COLORED
constexpr const char* LOG::LOG_PREFIX_COLORED[] |
|
staticconstexprprivate |
Initial value:= {
" - \x1B[38;5;39m\x1B[1m[INFO]\x1B[0m - ", " - \x1B[38;5;57m\x1B[1m[DEBUG]\x1B[0m - ",
" - \x1B[38;5;214m\x1B[1m[WARNING]\x1B[0m - ", " - \x1B[38;5;196m\x1B[1m[ERROR]\x1B[0m - ",
" - \x1B[38;5;124m\x1B[1m[FATAL]\x1B[0m - ",
}
Definition at line 38 of file LOG.hxx.
◆ m_Logger
std::ostringstream LOG::m_Logger |
|
private |
◆ m_LogType
◆ StreamMutex
The documentation for this class was generated from the following files: