diff mbox series

[1/1] mongoose: convert notify level to RFC 5424

Message ID 20211103142759.32461-1-james.hilliard1@gmail.com
State Accepted
Headers show
Series [1/1] mongoose: convert notify level to RFC 5424 | expand

Commit Message

James Hilliard Nov. 3, 2021, 2:27 p.m. UTC
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(-)

Comments

Stefano Babic Nov. 13, 2021, 2:27 p.m. UTC | #1
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 mbox series

Patch

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);