Skip to content

Added log ids to logs #440

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions src/FSHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,22 @@

namespace SlimeVR {
namespace Utils {
SlimeVR::Logging::Logger m_Logger("FSHelper");

enum class FSLogs {
FailedToCreateDir = 0,
FailedToRemoveDir = 1,
};

SlimeVR::Logging::Logger<FSLogs> m_Logger("FSHelper", "fs");

bool ensureDirectory(const char* directory) {
if (!LittleFS.exists(directory)) {
if (!LittleFS.mkdir(directory)) {
m_Logger.error("Failed to create directory: %s", directory);
m_Logger.error(
FSLogs::FailedToCreateDir,
"Failed to create directory: %s",
directory
);
return false;
}
}
Expand All @@ -43,12 +53,20 @@ bool ensureDirectory(const char* directory) {

if (!isDirectory) {
if (!LittleFS.remove(directory)) {
m_Logger.error("Failed to remove directory: %s", directory);
m_Logger.error(
FSLogs::FailedToRemoveDir,
"Failed to remove directory: %s",
directory
);
return false;
}

if (!LittleFS.mkdir(directory)) {
m_Logger.error("Failed to create directory: %s", directory);
m_Logger.error(
FSLogs::FailedToCreateDir,
"Failed to create directory: %s",
directory
);
return false;
}
}
Expand Down
2 changes: 0 additions & 2 deletions src/LEDManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,6 @@ class LEDManager {
unsigned long m_LastUpdate = millis();

uint8_t m_Pin;

Logging::Logger m_Logger = Logging::Logger("LEDManager");
};
} // namespace SlimeVR

Expand Down
2 changes: 1 addition & 1 deletion src/batterymonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void BatteryMonitor::Setup() {
}
}
if (address == 0) {
m_Logger.error("MCP3021 not found on I2C bus");
m_Logger.error(Logs::MCPNotFound, "MCP3021 not found on I2C bus");
}
#endif
}
Expand Down
6 changes: 5 additions & 1 deletion src/batterymonitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,11 @@ class BatteryMonitor {
float voltage = -1;
float level = -1;

SlimeVR::Logging::Logger m_Logger = SlimeVR::Logging::Logger("BatteryMonitor");
enum class Logs {
MCPNotFound = 0,
};

SlimeVR::Logging::Logger<Logs> m_Logger{"BatteryMonitor", "battery"};
};

#endif // SLIMEVR_BATTERYMONITOR_H_
Loading