Files
MuditaOS/module-utils/board/linux/log_linux.cpp
Mateusz Grzegorzek a60e27fa4b [EGD-4593] Dump logs to file on timeout
- Dump logs to file every 10 sec.
- max file size is 50 MB
  (after reaching it, no more logs will be logged),
- Add `LockGuard` with locking mechanism
  supporting IRQ and use it in `Logger`.
- Fix minor style issues in `Logger`.
- Add `mount_user_lfs_partition.py` script for mounting LFS on Linux FS
  in order to get `MuditaOS.log` file from `user` partition
2021-03-17 16:33:02 +01:00

46 lines
1.7 KiB
C++

// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#include "log/log.hpp"
#include "log/Logger.hpp"
#include <iostream>
#include <string_view>
#include <ticks.hpp>
namespace Log
{
void Logger::addLogHeader(logger_level level, const char *file, int line, const char *function)
{
loggerBufferCurrentPos += snprintf(&loggerBuffer[loggerBufferCurrentPos],
LOGGER_BUFFER_SIZE - loggerBufferCurrentPos,
"%d ms ",
cpp_freertos::Ticks::TicksToMs(cpp_freertos::Ticks::GetTicks()));
loggerBufferCurrentPos += snprintf(&loggerBuffer[loggerBufferCurrentPos],
LOGGER_BUFFER_SIZE - loggerBufferCurrentPos,
"%s%-5s %s%s:%s:%d:%s ",
logColors->levelColors[level].data(),
levelNames[level],
logColors->callerInfoColor.data(),
file,
function,
line,
logColors->resetColor.data());
}
bool Logger::filterLogs(logger_level _level)
{
return _level >= level;
}
void Logger::logToDevice(const char *, va_list)
{
assert(false && "Not implemented");
}
void Logger::logToDevice(Device, std::string_view logMsg, size_t)
{
std::cout << logMsg;
}
} // namespace Log