#include "aes67_syslog.h" #include #include "aes67_cfg.h" // facility: 16 = local0 (PRI = facility * 8 + severity). static const char LOG_DEFAULTS[] = "{\"syslog\":false,\"host\":\"\",\"port\":514,\"level\":\"info\",\"facility\":16,\"format\":\"rfc5424\"}"; static bool log_validate(const cJSON *g, char *err, size_t n) { static const char *const levels[] = { "error", "warn", "info", "debug", NULL }; static const char *const formats[] = { "rfc5424", "rfc3164", NULL }; static const double facilities[] = { 1, 3, 16, 17, 18, 19, 20, 21, 22, 23 }; bool on = cJSON_IsTrue(cJSON_GetObjectItemCaseSensitive(g, "syslog")); return cfg_check_str(g, "host", on ? 1 : 0, 63, err, n) && cfg_check_int(g, "port", 1, 65535, err, n) && cfg_check_enum(g, "level", levels, err, n) && cfg_check_num_in(g, "facility", facilities, 10, err, n) && cfg_check_enum(g, "format", formats, err, n); } esp_err_t aes67_syslog_init(void) { return cfg_register("log", LOG_DEFAULTS, log_validate, NULL); }