Message ID | 20211103142759.32461-1-james.hilliard1@gmail.com |
---|---|
State | Accepted |
Headers | show |
Series | [1/1] mongoose: convert notify level to RFC 5424 | expand |
Hi James, On 03.11.21 15:27, James Hilliard wrote: > This maps swupdate notify levels to RFC 5424 levels for the web > interface. > > Signed-off-by: James Hilliard <james.hilliard1@gmail.com> > --- > mongoose/mongoose_interface.c | 18 +++++++++++++++++- > 1 file changed, 17 insertions(+), 1 deletion(-) > > diff --git a/mongoose/mongoose_interface.c b/mongoose/mongoose_interface.c > index 1878101..31548cc 100644 > --- a/mongoose/mongoose_interface.c > +++ b/mongoose/mongoose_interface.c > @@ -121,6 +121,22 @@ static void restart_handler(struct mg_connection *nc, int ev, void *ev_data) > } > } > > +static int level_to_rfc_5424(int level) > +{ > + switch(level) { > + case ERRORLEVEL: > + return 3; > + case WARNLEVEL: > + return 4; > + case INFOLEVEL: > + return 6; > + case TRACELEVEL: > + case DEBUGLEVEL: > + default: > + return 7; > + } > +} > + > static void broadcast_callback(struct mg_connection *nc, int ev, void *ev_data) > { > char *buf = (char *) ev_data; > @@ -174,7 +190,7 @@ static void *broadcast_message_thread(void *data) > "\t\"level\": \"%d\",\r\n" > "\t\"text\": \"%s\"\r\n" > "}\r\n", > - msg.data.notify.level, /* RFC 5424 */ > + level_to_rfc_5424(msg.data.notify.level), /* RFC 5424 */ > text); > > broadcast(mgr, str); > Applied to -master, thanks ! Best regards, Stefano Babic
diff --git a/mongoose/mongoose_interface.c b/mongoose/mongoose_interface.c index 1878101..31548cc 100644 --- a/mongoose/mongoose_interface.c +++ b/mongoose/mongoose_interface.c @@ -121,6 +121,22 @@ static void restart_handler(struct mg_connection *nc, int ev, void *ev_data) } } +static int level_to_rfc_5424(int level) +{ + switch(level) { + case ERRORLEVEL: + return 3; + case WARNLEVEL: + return 4; + case INFOLEVEL: + return 6; + case TRACELEVEL: + case DEBUGLEVEL: + default: + return 7; + } +} + static void broadcast_callback(struct mg_connection *nc, int ev, void *ev_data) { char *buf = (char *) ev_data; @@ -174,7 +190,7 @@ static void *broadcast_message_thread(void *data) "\t\"level\": \"%d\",\r\n" "\t\"text\": \"%s\"\r\n" "}\r\n", - msg.data.notify.level, /* RFC 5424 */ + level_to_rfc_5424(msg.data.notify.level), /* RFC 5424 */ text); broadcast(mgr, str);
This maps swupdate notify levels to RFC 5424 levels for the web interface. Signed-off-by: James Hilliard <james.hilliard1@gmail.com> --- mongoose/mongoose_interface.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)