mirror of
https://github.com/Telecominfraproject/wlan-ucentral-client.git
synced 2026-01-27 02:23:32 +00:00
client: add severity to log messages
Signed-off-by: John Crispin <john@phrozen.org>
This commit is contained in:
@@ -31,9 +31,9 @@ crashlog_init(void)
|
||||
if (tb[CRASH_LOG])
|
||||
crashlog_send(tb[CRASH_LOG]);
|
||||
else
|
||||
log_send("failed to parse the crashlog");
|
||||
log_send("failed to parse the crashlog", LOG_ERR);
|
||||
} else {
|
||||
log_send("found a crashlog that is not valid json");
|
||||
log_send("found a crashlog that is not valid json", LOG_ERR);
|
||||
}
|
||||
blob_buf_free(&crashlog);
|
||||
unlink(CRASHLOG);
|
||||
|
||||
10
proto.c
10
proto.c
@@ -120,7 +120,7 @@ connect_send(void)
|
||||
blobmsg_add_u64(&proto, "uuid", uuid_active ? uuid_active : 1);
|
||||
c = blobmsg_open_table(&proto, "capabilities");
|
||||
if (!blobmsg_add_json_from_file(&proto, path)) {
|
||||
log_send("failed to load capabilities");
|
||||
log_send("failed to load capabilities", LOG_ERR);
|
||||
return;
|
||||
}
|
||||
blobmsg_close_table(&proto, c);
|
||||
@@ -305,13 +305,13 @@ stats_send(struct blob_attr *a)
|
||||
}
|
||||
|
||||
void
|
||||
log_send(char *message)
|
||||
log_send(char *message, int severity)
|
||||
{
|
||||
void *m = proto_new_blob("log");
|
||||
|
||||
blobmsg_add_string(&proto, "serial", client.serial);
|
||||
blobmsg_add_string(&proto, "log", message);
|
||||
blobmsg_add_u32(&proto, "severity", LOG_INFO);
|
||||
blobmsg_add_u32(&proto, "severity", severity);
|
||||
blobmsg_close_table(&proto, m);
|
||||
ULOG_ERR("%s\n", message);
|
||||
proto_send_blob();
|
||||
@@ -670,7 +670,7 @@ proto_handle_blob(void)
|
||||
if (!rpc[JSONRPC_VER] || (!rpc[JSONRPC_METHOD] && !rpc[JSONRPC_ERROR]) ||
|
||||
(rpc[JSONRPC_METHOD] && !rpc[JSONRPC_PARAMS]) ||
|
||||
strcmp(blobmsg_get_string(rpc[JSONRPC_VER]), "2.0")) {
|
||||
log_send("received invalid jsonrpc call");
|
||||
log_send("received invalid jsonrpc call", LOG_ERR);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -708,7 +708,7 @@ proto_handle(char *cmd)
|
||||
|
||||
blob_buf_init(&proto, 0);
|
||||
if (!blobmsg_add_json_from_string(&proto, cmd)) {
|
||||
log_send("failed to parse command");
|
||||
log_send("failed to parse command", LOG_CRIT);
|
||||
return;
|
||||
}
|
||||
proto_handle_blob();
|
||||
|
||||
8
ubus.c
8
ubus.c
@@ -38,11 +38,13 @@ static int ubus_send_cb(struct ubus_context *ctx,
|
||||
|
||||
enum {
|
||||
LOG_MSG,
|
||||
LOG_SEVERITY,
|
||||
__LOG_MAX,
|
||||
};
|
||||
|
||||
static const struct blobmsg_policy log_policy[__LOG_MAX] = {
|
||||
[LOG_MSG] = { .name = "msg", .type = BLOBMSG_TYPE_STRING },
|
||||
[LOG_SEVERITY] = { .name = "severity", .type = BLOBMSG_TYPE_INT32 },
|
||||
};
|
||||
|
||||
static int ubus_log_cb(struct ubus_context *ctx,
|
||||
@@ -51,12 +53,16 @@ static int ubus_log_cb(struct ubus_context *ctx,
|
||||
const char *method, struct blob_attr *msg)
|
||||
{
|
||||
struct blob_attr *tb[__LOG_MAX] = {};
|
||||
int severity = LOG_INFO;
|
||||
|
||||
blobmsg_parse(log_policy, __LOG_MAX, tb, blobmsg_data(msg), blobmsg_data_len(msg));
|
||||
if (!tb[LOG_MSG])
|
||||
return UBUS_STATUS_INVALID_ARGUMENT;
|
||||
|
||||
log_send(blobmsg_get_string(tb[LOG_MSG]));
|
||||
if (tb[LOG_SEVERITY])
|
||||
severity = blobmsg_get_u32(tb[LOG_SEVERITY]);
|
||||
|
||||
log_send(blobmsg_get_string(tb[LOG_MSG]), severity);
|
||||
|
||||
return UBUS_STATUS_OK;
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ int cmd_run(struct blob_attr *tb, uint32_t id);
|
||||
void connect_send(void);
|
||||
void ping_send(void);
|
||||
void raw_send(struct blob_attr *a);
|
||||
void log_send(char *message);
|
||||
void log_send(char *message, int severity);
|
||||
void health_send(uint32_t sanity, struct blob_attr *a);
|
||||
void result_send(uint32_t id, struct blob_attr *a, uint32_t uuid);
|
||||
void result_send_error(uint32_t error, char *text, uint32_t retcode, uint32_t id);
|
||||
|
||||
8
upload.c
8
upload.c
@@ -36,10 +36,10 @@ upload_complete_cb(struct task *t, time_t uuid, uint32_t id, int ret)
|
||||
|
||||
if (ret) {
|
||||
ULOG_ERR("ucentral: curl returned (%d)", ret);
|
||||
log_send("failed to upload file");
|
||||
log_send("failed to upload file", LOG_ERR);
|
||||
return;
|
||||
}
|
||||
log_send("upload complete");
|
||||
log_send("upload complete", LOG_INFO);
|
||||
}
|
||||
|
||||
struct task upload_task = {
|
||||
@@ -67,7 +67,7 @@ upload_run(struct blob_attr *a)
|
||||
uint32_t id = 0;
|
||||
|
||||
if (upload_pending) {
|
||||
log_send("could not upload file due to another pending upload");
|
||||
log_send("could not upload file due to another pending upload", LOG_WARNING);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ upload_run(struct blob_attr *a)
|
||||
blobmsg_data_len(a));
|
||||
|
||||
if (!tb[UPLOAD_UUID] || !tb[UPLOAD_FILE] || !tb[UPLOAD_URI]) {
|
||||
log_send("invalid upload request");
|
||||
log_send("invalid upload request", LOG_ERR);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user