Reformatting lib files and am starting to add DOxygen comments

This commit is contained in:
John Poole 2026-04-24 16:30:27 -07:00
commit 6fdbf1d258
5 changed files with 955 additions and 638 deletions

View file

@ -1,78 +1,98 @@
#include "TBeamLogger.h"
namespace tbeam {
namespace tbeam
{
bool TBeamLogger::begin(Print& serial, TBeamStorage* storage, const LoggerConfig& config) {
serial_ = &serial;
storage_ = storage;
config_ = config;
lastFlushMs_ = millis();
return true;
}
void TBeamLogger::update() {
if (!config_.autoFlush || !storage_) {
return;
bool TBeamLogger::begin(Print &serial, TBeamStorage *storage, const LoggerConfig &config)
{
serial_ = &serial;
storage_ = storage;
config_ = config;
lastFlushMs_ = millis();
return true;
}
const uint32_t now = millis();
if ((uint32_t)(now - lastFlushMs_) >= config_.flushIntervalMs) {
storage_->flush();
lastFlushMs_ = now;
void TBeamLogger::update()
{
if (!config_.autoFlush || !storage_)
{
return;
}
const uint32_t now = millis();
if ((uint32_t)(now - lastFlushMs_) >= config_.flushIntervalMs)
{
storage_->flush();
lastFlushMs_ = now;
}
}
}
bool TBeamLogger::openLog(const char* path) {
return storage_ && storage_->openLog(path);
}
bool TBeamLogger::openUniqueLog(const char* prefix, const char* extension) {
if (!storage_) {
return false;
bool TBeamLogger::openLog(const char *path)
{
return storage_ && storage_->openLog(path);
}
char path[128];
if (!storage_->makeUniqueLogPath(prefix, extension, path, sizeof(path))) {
return false;
bool TBeamLogger::openUniqueLog(const char *prefix, const char *extension)
{
if (!storage_)
{
return false;
}
char path[128];
if (!storage_->makeUniqueLogPath(prefix, extension, path, sizeof(path)))
{
return false;
}
return storage_->openLog(path);
}
return storage_->openLog(path);
}
const char* TBeamLogger::currentLogPath() const {
return storage_ ? storage_->currentLogPath() : "";
}
bool TBeamLogger::storageReady() const {
return storage_ && storage_->ready() && storage_->isLogOpen();
}
void TBeamLogger::flush() {
if (storage_) {
storage_->flush();
const char *TBeamLogger::currentLogPath() const
{
return storage_ ? storage_->currentLogPath() : "";
}
if (serial_) {
serial_->flush();
}
}
void TBeamLogger::closeLog() {
if (storage_) {
storage_->closeLog();
bool TBeamLogger::storageReady() const
{
return storage_ && storage_->ready() && storage_->isLogOpen();
}
}
size_t TBeamLogger::write(uint8_t value) {
return write(&value, 1);
}
size_t TBeamLogger::write(const uint8_t* buffer, size_t size) {
size_t serialWrote = 0;
size_t storageWrote = 0;
if (config_.echoSerial && serial_) {
serialWrote = serial_->write(buffer, size);
void TBeamLogger::flush()
{
if (storage_)
{
storage_->flush();
}
if (serial_)
{
serial_->flush();
}
}
if (config_.echoStorage && storage_ && storage_->isLogOpen()) {
storageWrote = storage_->write(buffer, size);
}
return storageWrote > 0 ? storageWrote : serialWrote;
}
} // namespace tbeam
void TBeamLogger::closeLog()
{
if (storage_)
{
storage_->closeLog();
}
}
size_t TBeamLogger::write(uint8_t value)
{
return write(&value, 1);
}
size_t TBeamLogger::write(const uint8_t *buffer, size_t size)
{
size_t serialWrote = 0;
size_t storageWrote = 0;
if (config_.echoSerial && serial_)
{
serialWrote = serial_->write(buffer, size);
}
if (config_.echoStorage && storage_ && storage_->isLogOpen())
{
storageWrote = storage_->write(buffer, size);
}
return storageWrote > 0 ? storageWrote : serialWrote;
}
} // namespace tbeam