Log Management

2023-09-11
No Rating

Catalog

Definition, Enum and Struct

typedef enum LogLevel

Log Level

enum LogLevel {
kLevelError = 0,
kLevelWarn = 1,
kLevelInfo = 2,
kLevelDebug = 3,
};

typedef struct LoggerConsole

Log Console Configuration

struct LoggerConsole {
/*! Log output function definition */
using OutputFunc = std::function<ErrorCode(const uint8_t *, uint32_t)>;

/*! Filters log level. Only logs with this level or lower will be output. */
LogLevel level;

/*! Log output process function */
OutputFunc output_func;

/*! Determines if the console supports color display */
bool is_support_color;
};

Function

function EdgeSDKLoggerOutput

void EdgeSDKLoggerOutput(LogLevel level, const char *fmt, ...);

#define DEBUG(fmt, ...)                                                      \
    EdgeSDKLoggerOutput(kLevelDebug, "[%s:%d) " fmt, __FUNCTION__, __LINE__, \
                        ##__VA_ARGS__)

#define INFO(fmt, ...)                                                      \
    EdgeSDKLoggerOutput(kLevelInfo, "[%s:%d) " fmt, __FUNCTION__, __LINE__, \
                        ##__VA_ARGS__)

#define WARN(fmt, ...)                                                      \
    EdgeSDKLoggerOutput(kLevelWarn, "[%s:%d) " fmt, __FUNCTION__, __LINE__, \
                        ##__VA_ARGS__)

#define ERROR(fmt, ...)                                                      \
    EdgeSDKLoggerOutput(kLevelError, "[%s:%d) " fmt, __FUNCTION__, __LINE__, \
                        ##__VA_ARGS__)