2015-07-10 06:01:56 -07:00
|
|
|
/**
|
|
|
|
* @file loggingcentral.h
|
|
|
|
*
|
|
|
|
* @date Mar 8, 2015
|
2020-01-13 18:57:43 -08:00
|
|
|
* @author Andrey Belomutskiy, (c) 2012-2020
|
2015-07-10 06:01:56 -07:00
|
|
|
*/
|
2020-04-01 18:32:21 -07:00
|
|
|
#pragma once
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2021-04-18 15:46:47 -07:00
|
|
|
#include <cstddef>
|
2021-04-28 19:41:25 -07:00
|
|
|
#include "rusefi_generated.h"
|
|
|
|
|
2020-03-30 15:29:42 -07:00
|
|
|
class Logging;
|
|
|
|
|
2021-04-18 15:46:47 -07:00
|
|
|
void startLoggingProcessor();
|
|
|
|
|
|
|
|
const char* swapOutputBuffers(size_t *actualOutputBufferSize);
|
|
|
|
|
|
|
|
namespace priv
|
|
|
|
{
|
2021-04-21 12:33:40 -07:00
|
|
|
// internal implementation, use efiPrintf below
|
2021-04-18 15:46:47 -07:00
|
|
|
void efiPrintfInternal(const char *fmt, ...);
|
|
|
|
}
|
|
|
|
|
|
|
|
// "normal" logging messages need a header and footer, so put them in
|
|
|
|
// the format string at compile time
|
2021-11-19 01:01:45 -08:00
|
|
|
#define efiPrintf(fmt, ...) priv::efiPrintfInternal(PROTOCOL_MSG LOG_DELIMITER fmt LOG_DELIMITER, ##__VA_ARGS__)
|
2021-04-18 15:46:47 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This is the legacy function to copy the contents of a local Logging object in to the output buffer
|
|
|
|
*/
|
|
|
|
void scheduleLogging(Logging *logging);
|
|
|
|
|
|
|
|
// Stores the result of one call to efiPrintfInternal in the queue to be copied out to the output buffer
|
|
|
|
struct LogLineBuffer {
|
|
|
|
char buffer[128];
|
|
|
|
};
|
|
|
|
|
|
|
|
template <size_t TBufferSize>
|
|
|
|
class LogBuffer {
|
|
|
|
public:
|
|
|
|
void writeLine(LogLineBuffer* line);
|
|
|
|
void writeLogger(Logging* logging);
|
|
|
|
|
|
|
|
size_t length() const;
|
|
|
|
void reset();
|
|
|
|
const char* get() const;
|
|
|
|
|
|
|
|
#if !EFI_UNIT_TEST
|
|
|
|
private:
|
|
|
|
#endif
|
|
|
|
void writeInternal(const char* buffer);
|
|
|
|
|
|
|
|
char m_buffer[TBufferSize];
|
|
|
|
char* m_writePtr = m_buffer;
|
|
|
|
};
|