68 lines
1.4 KiB
C++
68 lines
1.4 KiB
C++
#pragma once
|
|
|
|
#include <Arduino.h>
|
|
|
|
#include "FilamentGuardApiClient.h"
|
|
#include "FilamentGuardDeviceInfo.h"
|
|
#include "FilamentGuardLogEntry.h"
|
|
#include "FilamentGuardLogEntrySerializer.h"
|
|
|
|
class FilamentGuardLogger
|
|
{
|
|
public:
|
|
void begin(
|
|
const String& firmwareVersion);
|
|
|
|
void setDeviceInfo(
|
|
const FilamentGuardDeviceInfo& deviceInfo);
|
|
|
|
void setTagUid(
|
|
const String& tagUid);
|
|
|
|
void info(
|
|
const String& category,
|
|
const String& message,
|
|
const String& data = String());
|
|
|
|
void error(
|
|
const String& category,
|
|
const String& message,
|
|
const String& data = String());
|
|
|
|
void process();
|
|
|
|
private:
|
|
static constexpr size_t QueueSize = 20;
|
|
|
|
FilamentGuardLogEntry queue[QueueSize];
|
|
|
|
size_t queueStart = 0;
|
|
size_t queueCount = 0;
|
|
|
|
String firmwareVersion;
|
|
String tagUid;
|
|
FilamentGuardDeviceInfo deviceInfo;
|
|
|
|
bool hasDeviceInfo = false;
|
|
|
|
FilamentGuardLogEntrySerializer serializer;
|
|
FilamentGuardApiClient apiClient;
|
|
|
|
void log(
|
|
FilamentGuardLogLevel level,
|
|
const String& category,
|
|
const String& message,
|
|
const String& data);
|
|
|
|
void writeToSerial(
|
|
const FilamentGuardLogEntry& logEntry) const;
|
|
|
|
void enqueue(
|
|
const FilamentGuardLogEntry& logEntry);
|
|
|
|
bool tryPeek(
|
|
FilamentGuardLogEntry& logEntry) const;
|
|
|
|
void dequeue();
|
|
};
|