Veethree D7 SDK
Loading...
Searching...
No Matches
The log library

Detailed Description

Configurable logging system.

Namespaces

namespace  vsdk
 Any entities that belong to the Veethree SDK libraries.

Classes

class  vsdk::diag::log
 logging with module-based filtering More...

Enumerations

enum class  module : uint8_t {
  module::pwm_in , module::pwm_out , module::digital_in , module::digital_out ,
  module::analog , module::system , module::network , module::comms ,
  module::ct2klib , module::max
}
 Enumeration of available logging modules. More...

Detailed Description

Configurable logging system.

General Logging Configuration

Log Configuration File Format

The logging system is configured through /app/config/vsdk_log.json file (JSON format). Below is the format with explanations of each field:

{
"enabled": true, // Master enable/disable switch
"pattern": "[%H:%M:%S.%e] [%^%l%$] [%s:%# %!] %v", // Log format pattern
"level": "trace", // Global minimum log level
"console_output": false, // Enable/disable console output
"log_file": "/appdata/logs/vsdk.log", // Path to the log file
"enabled_modules": [ // List of enabled modules
"analog",
"digital_in",
"digital_out",
"pwm_in",
"pwm_out",
"system",
"network",
"comms",
"ct2klib",
]
}

Pattern Format

The pattern format follows spdlog conventions https://internal.dunescience.org/doxygen/classspdlog_1_1pattern__formatter.html

Log Levels

The following log levels are supported (from lowest to highest):

  • "trace": Very detailed debugging information
  • "debug": Debugging information
  • "info": Regular informational messages
  • "warn": Warning conditions
  • "error": Error conditions
  • "critical": Critical conditions
  • "off": Disable all logging

Messages at the configured level and higher will be logged.

Log File

The log file is located in /appdata/logs/vsdk.log

to disable file logging, just delete the "log_file" field from the configuration file.

Enabled Modules

Module names in the configuration must match the module enum values:

  • "pwm_in"
  • "pwm_out"
  • "digital_in"
  • "digital_out"
  • "analog"
  • "system"
  • "network"
  • "comms"
  • "ct2klib"

to disable logging for a module, remove it from the list of enabled modules.

Basic Logging Sample Code

The logging system provides macros for different log levels. Each macro requires a module parameter and supports fmt-style formatting:

#include <liblog/log.h>
void fn()
{
using namespace vsdk::diag;
LOG_INFO(module::system, "System initialized");
// Logging with formatted parameters
LOG_DEBUG(module::pwm_in, "PWM input on channel {} is set to {}Hz", channel, frequency);
// Logging with float formatting
LOG_INFO(module::analog, "Voltage reading: {:.2f}V", voltage);
// Error logging
LOG_ERROR(module::network, "Connection failed: {}", error_message);
}
@ analog
Analog module.
Definition log.h:38
@ system
System module.
Definition log.h:39
@ network
Network module.
Definition log.h:40
@ pwm_in
PWM input module.
Definition log.h:34
Logging interface.
#define LOG_ERROR(module,...)
Produce a log at the ERROR level.
Definition log.h:313
#define LOG_DEBUG(module,...)
Produce a log at the DEBUG level.
Definition log.h:280
#define LOG_INFO(module,...)
Produce a log at the INFO level.
Definition log.h:291

Enumeration Type Documentation

◆ module

enum class module : uint8_t
strong

Enumeration of available logging modules.

Enumerator
pwm_in 

PWM input module.

pwm_out 

PWM output module.

digital_in 

Digital input module.

digital_out 

Digital output module.

analog 

Analog module.

system 

System module.

network 

Network module.

comms 

Comms module.

ct2klib 

CT2KLib Compatibility module.

max 

Maximum number of modules.