From patchwork Thu Sep 28 12:56:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Storm, Christian" X-Patchwork-Id: 819593 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:400c:c0c::238; helo=mail-wr0-x238.google.com; envelope-from=swupdate+bncbdd6bwv65qpbbshewphakgqezlrutkq@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.b="LJDo3c/f"; dkim-atps=neutral Received: from mail-wr0-x238.google.com (mail-wr0-x238.google.com [IPv6:2a00:1450:400c:c0c::238]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3y2vt34qx0z9s06 for ; Thu, 28 Sep 2017 22:59:54 +1000 (AEST) Received: by mail-wr0-x238.google.com with SMTP id a43sf583936wrc.15 for ; Thu, 28 Sep 2017 05:59:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1506603592; cv=pass; d=google.com; s=arc-20160816; b=c9t9ouLgyRCajK3HMBfpuo38JYJXldp0ybYRzJjT33xg8WpnWR+Znp4OMAWVRoMHAy HiRO/B3pGCBVvixEUOW6pBgg4MMMGY/PTzUDeiBWmUECtmNvN95sbUz9Ia93/xfdyHYB 6doCUCU6rsyzyz1NGu5ufMWNHBjGO9sGJVa2/8OrQ9ynFpyLIs2VjY+L+CZZow2QDwE9 zjodDLbg9qd48LHg9915uBSgojTuiH9HSdKlGw9MNMH5VY6caa05nKBpO/24ltAhSq1b 5fwQw+f7r7PmfcDScRmNfRL8Qx9W1eVnNGR0oMXBUGyJh+Nru2WHyMw5OcuJkcSCMtPg lzZw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:message-id:date:subject:cc:to:from :arc-authentication-results:arc-message-signature:mime-version :sender:dkim-signature:arc-authentication-results; bh=L3Mdrkq+rmiYRawvN55ynI+ERBgadt3qt9gdFFUp3qc=; b=cwEgOb6nuiggclr2wcZDdhjkxFjcixKefe9ZruQcEG2raZml73yHm7+YcnVC5iMsBv T0j4xS45LwgMG1I4E5Ix1Sohn+lin3AsUviaejjF3vB4zeQG1p2mCLgNuAmMl4Y7jmMf 2STqP0C1OPCCyNZbNwCoOaxNndbvKpXybsTiudxddfovgfFx3jQCprT0utmLXZMLjcyr 1g7MavnIq3fj8ubDfdtE6O7JPff2j7Wz1hv3MMn9BH9jW0V2RFdvVSPScwwyn5eEDliQ uV8bhlAlSFgW6YemZGocRqgsA4U8nWaiseqgyQLVbOoRQlFhbx+wcCstY6KUwDGEneTW bUIQ== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 192.35.17.2 is neither permitted nor denied by best guess record for domain of christian.storm@siemens.com) smtp.mailfrom=christian.storm@siemens.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:mime-version:from:to:cc:subject:date:message-id :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=L3Mdrkq+rmiYRawvN55ynI+ERBgadt3qt9gdFFUp3qc=; b=LJDo3c/f+C50v0Z3JP97Petfvg8DhYsb9k428dpP7QwKSWOZ/KwaUTHl2HNj6wpLEs gSrcKfdJJL8dDc2T8qrB/36vo+yxks1HalQicNAkYcSxAvqrb7jMSjcQ6ILvfSEiSK2q KpkhARtuztCw4F/8mmSCVF1SgiZtbZb6JTDMBCaFKwHN2OT29pmhl57KTvPDEpEFqqQ1 SUGk/EFw+Mqef7f/JQuGISNV0aYfa+pygyFZrXl/WfJtZfFCF/SSUPx7N03IA/8hoRqw aHAR6QyTdqJ/Holarlxjj7n1jYJ6CwYNVaFK2DLAiViTfTTM80mEMSV18kVgQaaCsaR0 v1aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:mime-version:from:to:cc:subject:date :message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:x-spam-checked-in-group:list-post :list-help:list-archive:list-subscribe:list-unsubscribe; bh=L3Mdrkq+rmiYRawvN55ynI+ERBgadt3qt9gdFFUp3qc=; b=bo8X5mnv6TzoT6HvQIsE7G1ZRw6Hap+ZoUO3jGXnlGd3VEQPjekCh1rxPihBXoRbAV S7NjX9lNklLdHExaapoxPCJBaNUXympIzUZU5icHBGZGkr955F7xatl/PZ3yUYD6cpj2 tl0Na7ZljvpVXqpjh4wGDu2Cg2kYejztdQ/XJmL9p4kfF0ebKp5SSbgmbxtJMaceE06J HkqT7PpLF+4OKubxXy0c9O6yWre1vWdWhR6ZdM/tcqHAIQjFyz7o6rF2PplxRYu1wrT6 9jFngUtSA1NXZr5DkoIMSMJL1u+dceA3Z/gKr8tA+sj5aavZ2hxb1Z46mOrtiHXoOEsh Jw2Q== Sender: swupdate@googlegroups.com X-Gm-Message-State: AHPjjUgzGynfOJS/bmiJcKQq0MbH9Ihx2X4tSkxAaBRJ4q9YkKj+kKvH WMAELOZ0hf9D1pf+d7otjWA= X-Google-Smtp-Source: AOwi7QDoq7e9pHGwTzuo9FfyntfxqGTQTzd7kW5no3DEbNY6a5lYVggLak0Ha2M5LkGqTXpBBOz9fw== X-Received: by 10.28.143.5 with SMTP id r5mr4142wmd.26.1506603592539; Thu, 28 Sep 2017 05:59:52 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: swupdate@googlegroups.com Received: by 10.223.187.204 with SMTP id z12ls1140699wrg.10.gmail; Thu, 28 Sep 2017 05:59:52 -0700 (PDT) X-Received: by 10.28.140.199 with SMTP id o190mr142272wmd.6.1506603592161; Thu, 28 Sep 2017 05:59:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506603592; cv=none; d=google.com; s=arc-20160816; b=Ic+lzVHVRjwDUh0DprYcB50gm3HMGB3zK1qodxJ/eVL4MpzrWTxutwt+WPW1gRzuRw phj7krcQ6yVlF+qw8y3gpCLH+csT6TKWpzMF3Kewv7xoHJQwYSruiIZkmXmhnKN0MDc5 jSq8TBFoT3uRg3ZQj2Xphxpmk621SA6rZsEGywLeqclBHW8eEYlXklRPvnLjBfDbd1um /1grsuuzrMMaVZNte/cnLb7rWJYhgYVQ7flglHdTAlpREI1hh3i08dfx+K1Xp0DztP3U ySBboUxv7A0+wzzdX6W/40z/rYbKzGn/kDjcVMVC9ZfZ276HzrTHBIJQ0Cv1t9pX9gkh R7SQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:arc-authentication-results; bh=KoUhjXMsbtbwpjBdEGVQm5MBSiN4F2f45H+rc3ewgL0=; b=bJE30ne3o0Cabf2vGysLDICjYNXQyJ5kSIFir4nINFJU4OSjQ1mnf5J+lDWHHy37Jg xZ5bav42fIg72HVjbAcNiiiYa3FgzR/fT0+TlLU4CzSAqDYoslt+BsZLD7+7zGfD76l4 CGIeFfQDMcgUuUVMjz5oMrowVNvuGZRevTuSHQVhOw5QBfm7KqksM9UELRCOImEWTIb3 a1S+Hp8W/zyAnDkoQNNGuy3oRnIi2YzZdiEz8iv5JInJEppVvMi3uCu2rGgXxX87tur5 DOjuGc9VD6OJM4Rchcn/8/a91j6bkRDMNvOq8LI5QDElIa6GZr+IhM8J1+QmXFQ3TCI9 1T7A== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 192.35.17.2 is neither permitted nor denied by best guess record for domain of christian.storm@siemens.com) smtp.mailfrom=christian.storm@siemens.com Received: from thoth.sbs.de (thoth.sbs.de. [192.35.17.2]) by gmr-mx.google.com with ESMTPS id r65si94156wmf.2.2017.09.28.05.59.52 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Sep 2017 05:59:52 -0700 (PDT) Received-SPF: neutral (google.com: 192.35.17.2 is neither permitted nor denied by best guess record for domain of christian.storm@siemens.com) client-ip=192.35.17.2; Received: from mail1.siemens.de (mail1.siemens.de [139.23.33.14]) by thoth.sbs.de (8.15.2/8.15.2) with ESMTPS id v8SCxpkc028128 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 28 Sep 2017 14:59:51 +0200 Received: from MD1KR9XC.ww002.siemens.net ([139.25.69.251]) by mail1.siemens.de (8.15.2/8.15.2) with ESMTP id v8SCxp1N019194; Thu, 28 Sep 2017 14:59:51 +0200 From: Christian Storm To: swupdate@googlegroups.com Cc: Christian Storm Subject: [swupdate] [PATCH 1/2] logging: pass through and make use of loglevel Date: Thu, 28 Sep 2017 14:56:51 +0200 Message-Id: <20170928125652.2920-1-christian.storm@siemens.com> X-Mailer: git-send-email 2.14.2 X-Original-Sender: christian.storm@siemens.com X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 192.35.17.2 is neither permitted nor denied by best guess record for domain of christian.storm@siemens.com) smtp.mailfrom=christian.storm@siemens.com Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Although there are distinct macros for logging messages of different priorities (INFO, DEBUG, WARN, ...), the different notifiers emitting the log messages cannot make use of this distinction and log messages with the same uniform priority. Hence, pass through the loglevel to the notifiers emitting the log messages so that they may log respecting the intended priority. Consequently, adapt the notifiers to make use of this information, e.g., console_notifier now prefixes log messages with their priority information: ... [TRACE] : SWUPDATE running : [network_initializer] : Valid image found: copying to FLASH [INFO ] : SWUPDATE running : Installation in progress ... Signed-off-by: Christian Storm Acked-by: Stefano Babic --- core/notifier.c | 34 ++++++++++++++++++++++++++++------ core/swupdate.c | 2 +- core/syslog.c | 15 ++++++++++++--- corelib/downloader.c | 2 +- corelib/lua_interface.c | 2 +- corelib/network_thread.c | 4 +++- corelib/stream_interface.c | 14 +++++++------- handlers/boot_handler.c | 14 +++++++------- handlers/ubivol_handler.c | 2 +- include/util.h | 8 ++++---- suricatta/server_hawkbit.c | 8 ++++---- 11 files changed, 69 insertions(+), 36 deletions(-) diff --git a/core/notifier.c b/core/notifier.c index 5c7dd7b..cb75996 100644 --- a/core/notifier.c +++ b/core/notifier.c @@ -60,6 +60,7 @@ static struct notifylist clients; struct notify_ipc_msg { RECOVERY_STATUS status; int error; + int level; char buf[NOTIFY_BUF_SIZE]; }; @@ -96,7 +97,7 @@ int register_notifier(notifier client) * IPC to the main process that will dispatch it * to the notifiers. */ -void notify(RECOVERY_STATUS status, int error, const char *msg) +void notify(RECOVERY_STATUS status, int error, int level, const char *msg) { struct notify_elem *elem; struct notify_ipc_msg notifymsg; @@ -105,6 +106,7 @@ void notify(RECOVERY_STATUS status, int error, const char *msg) if (notifyfd > 0) { notifymsg.status = status; notifymsg.error = error; + notifymsg.level = level; if (msg) strcpy(notifymsg.buf, msg); else @@ -115,14 +117,14 @@ void notify(RECOVERY_STATUS status, int error, const char *msg) } } else { /* Main process */ STAILQ_FOREACH(elem, &clients, next) - (elem->client)(status, error, msg); + (elem->client)(status, error, level, msg); } } /* * Default notifier, it prints to stdout */ -static void console_notifier (RECOVERY_STATUS status, int error, const char *msg) +static void console_notifier (RECOVERY_STATUS status, int error, int level, const char *msg) { char current[80]; switch(status) { @@ -152,7 +154,26 @@ static void console_notifier (RECOVERY_STATUS status, int error, const char *msg break; } - fprintf(stdout, "[NOTIFY] : %s %s\n", current, msg ? msg : ""); + switch (level) { + case ERRORLEVEL: + fprintf(stderr, "[ERROR]"); + break; + case WARNLEVEL: + fprintf(stdout, "[WARN ]"); + break; + case INFOLEVEL: + fprintf(stdout, "[INFO ]"); + break; + case DEBUGLEVEL: + fprintf(stdout, "[DEBUG]"); + break; + case TRACELEVEL: + fprintf(stdout, "[TRACE]"); + break; + } + + fprintf(level == ERRORLEVEL ? stderr : stdout, + " : %s %s\n", current, msg ? msg : ""); fflush(stdout); } @@ -160,8 +181,9 @@ static void console_notifier (RECOVERY_STATUS status, int error, const char *msg * Process notifier: this is called when a process has something to say * and wants that the information is passed to the progress interface */ -static void process_notifier (RECOVERY_STATUS status, int event, const char *msg) +static void process_notifier (RECOVERY_STATUS status, int event, int level, const char *msg) { + (void)level; /* Check just in case a process want to send an info outside */ if (status != SUBPROCESS) @@ -226,7 +248,7 @@ static void *notifier_thread (void __attribute__ ((__unused__)) *data) len = recvfrom(serverfd, &msg, sizeof(msg), 0, NULL, NULL); if (len > 0) { - notify(msg.status, msg.error, msg.buf); + notify(msg.status, msg.error, msg.level, msg.buf); } } while(1); diff --git a/core/swupdate.c b/core/swupdate.c index ef94bd9..a9c71cf 100644 --- a/core/swupdate.c +++ b/core/swupdate.c @@ -862,7 +862,7 @@ int main(int argc, char **argv) install_from_file(fname, opt_c); cleanup_files(&swcfg); - notify(SUCCESS, 0, 0); + notify(SUCCESS, 0, INFOLEVEL, NULL); if (postupdate(&swcfg, NULL) != 0) { ERROR("Post-update command execution failed."); } diff --git a/core/syslog.c b/core/syslog.c index d031ed1..88b1218 100644 --- a/core/syslog.c +++ b/core/syslog.c @@ -20,7 +20,7 @@ #include #include "util.h" -static void syslog_notifier(RECOVERY_STATUS status, int error, const char *msg); +static void syslog_notifier(RECOVERY_STATUS status, int error, int level, const char *msg); int syslog_init(void) { @@ -28,7 +28,7 @@ int syslog_init(void) return register_notifier(syslog_notifier); } -void syslog_notifier(RECOVERY_STATUS status, int error, const char *msg) +void syslog_notifier(RECOVERY_STATUS status, int error, int level, const char *msg) { const char* statusMsg; @@ -45,7 +45,16 @@ void syslog_notifier(RECOVERY_STATUS status, int error, const char *msg) default: statusMsg = "UNKNOWN"; break; } - syslog(LOG_NOTICE, "%s%s %s\n", ((error != (int)RECOVERY_NO_ERROR) ? "FATAL_" : ""), statusMsg, msg); + int logprio = LOG_INFO; + switch (level) { + case ERRORLEVEL: logprio = LOG_ERR; break; + case WARNLEVEL: logprio = LOG_WARNING; break; + case INFOLEVEL: logprio = LOG_INFO; break; + case DEBUGLEVEL: + case TRACELEVEL: logprio = LOG_DEBUG; break; + } + + syslog(logprio, "%s%s %s\n", ((error != (int)RECOVERY_NO_ERROR) ? "FATAL_" : ""), statusMsg, msg); closelog(); } diff --git a/corelib/downloader.c b/corelib/downloader.c index 58589f3..27bb4e8 100644 --- a/corelib/downloader.c +++ b/corelib/downloader.c @@ -237,7 +237,7 @@ static RECOVERY_STATUS download_from_url(char *image_url, unsigned int retries, } /* We are starting a download */ - notify(DOWNLOAD, 0, 0); + notify(DOWNLOAD, 0, INFOLEVEL, NULL); curl_global_init(CURL_GLOBAL_ALL); curl_handle = curl_easy_init(); diff --git a/corelib/lua_interface.c b/corelib/lua_interface.c index 5717807..5f48726 100644 --- a/corelib/lua_interface.c +++ b/corelib/lua_interface.c @@ -304,7 +304,7 @@ static int l_notify (lua_State *L) { const char *msg = luaL_checkstring (L, 3); if (strlen(msg)) - notify((RECOVERY_STATUS)status, (int)error, msg); + notify((RECOVERY_STATUS)status, (int)error, INFOLEVEL, msg); return 0; } diff --git a/corelib/network_thread.c b/corelib/network_thread.c index 747ee1b..8c2b3b6 100644 --- a/corelib/network_thread.c +++ b/corelib/network_thread.c @@ -56,6 +56,7 @@ struct msg_elem { RECOVERY_STATUS status; int error; + int level; char *msg; SIMPLEQ_ENTRY(msg_elem) next; }; @@ -76,7 +77,7 @@ static void clean_msg(char *msg, char drop) } } -static void network_notifier(RECOVERY_STATUS status, int error, const char *msg) +static void network_notifier(RECOVERY_STATUS status, int error, int level, const char *msg) { int len = msg ? strlen(msg) : 0; struct msg_elem *newmsg = (struct msg_elem *)calloc(1, sizeof(*newmsg) + len + 1); @@ -97,6 +98,7 @@ static void network_notifier(RECOVERY_STATUS status, int error, const char *msg) newmsg->status = status; newmsg->error = error; + newmsg->level = level; if (msg) { strncpy(newmsg->msg, msg, len); diff --git a/corelib/stream_interface.c b/corelib/stream_interface.c index fb56c96..404c116 100644 --- a/corelib/stream_interface.c +++ b/corelib/stream_interface.c @@ -309,14 +309,14 @@ void *network_initializer(void *data) /* handle installation requests (from either source) */ while (1) { - printf ("Main loop Daemon\n"); + TRACE("Main loop Daemon"); /* wait for someone to issue an install request */ pthread_mutex_lock(&stream_mutex); pthread_cond_wait(&stream_wkup, &stream_mutex); inst.status = RUN; pthread_mutex_unlock(&stream_mutex); - notify(START, RECOVERY_NO_ERROR, "Software Update started !"); + notify(START, RECOVERY_NO_ERROR, INFOLEVEL, "Software Update started !"); #ifdef CONFIG_MTD mtd_cleanup(); @@ -340,11 +340,11 @@ void *network_initializer(void *data) */ bootloader_env_set("recovery_status", "in_progress"); - notify(RUN, RECOVERY_NO_ERROR, "Installation in progress"); + notify(RUN, RECOVERY_NO_ERROR, INFOLEVEL, "Installation in progress"); ret = install_images(software, 0, 0); if (ret != 0) { bootloader_env_set("recovery_status", "failed"); - notify(FAILURE, RECOVERY_ERROR, "Installation failed !"); + notify(FAILURE, RECOVERY_ERROR, ERRORLEVEL, "Installation failed !"); inst.last_install = FAILURE; } else { @@ -353,12 +353,12 @@ void *network_initializer(void *data) * that it is not required to start recovery again */ bootloader_env_unset("recovery_status"); - notify(SUCCESS, RECOVERY_NO_ERROR, "SWUPDATE successful !"); + notify(SUCCESS, RECOVERY_NO_ERROR, INFOLEVEL, "SWUPDATE successful !"); inst.last_install = SUCCESS; } } else { inst.last_install = FAILURE; - notify(FAILURE, RECOVERY_ERROR, "Image invalid or corrupted. Not installing ..."); + notify(FAILURE, RECOVERY_ERROR, ERRORLEVEL, "Image invalid or corrupted. Not installing ..."); } swupdate_progress_end(inst.last_install); @@ -367,7 +367,7 @@ void *network_initializer(void *data) inst.status = IDLE; pthread_mutex_unlock(&stream_mutex); TRACE("Main thread sleep again !"); - notify(IDLE, RECOVERY_NO_ERROR, "Waiting for requests..."); + notify(IDLE, RECOVERY_NO_ERROR, INFOLEVEL, "Waiting for requests..."); /* release temp files we may have created */ cleanup_files(software); diff --git a/handlers/boot_handler.c b/handlers/boot_handler.c index 41f87f7..86c55d0 100644 --- a/handlers/boot_handler.c +++ b/handlers/boot_handler.c @@ -39,7 +39,6 @@ static int install_boot_environment(struct img_type *img, { int ret; int fdout; - char buf[64]; char filename[64]; struct stat statbuf; @@ -62,12 +61,13 @@ static int install_boot_environment(struct img_type *img, } ret = bootloader_apply_list(filename); - if (ret < 0) - snprintf(buf, sizeof(buf), "Error setting bootloader environment"); - else - snprintf(buf, sizeof(buf), "Bootloader environment updated"); - - notify(RUN, RECOVERY_NO_ERROR, buf); + if (ret < 0) { + notify(RUN, RECOVERY_NO_ERROR, ERRORLEVEL, + "Error setting bootloader environment"); + } else { + notify(RUN, RECOVERY_NO_ERROR, INFOLEVEL, + "Bootloader environment updated"); + } return ret; } diff --git a/handlers/ubivol_handler.c b/handlers/ubivol_handler.c index bf58658..0e262b6 100644 --- a/handlers/ubivol_handler.c +++ b/handlers/ubivol_handler.c @@ -100,7 +100,7 @@ static int update_volume(libubi_t libubi, struct img_type *img, snprintf(sbuf, sizeof(sbuf), "Installing image %s into volume %s(%s)", img->fname, node, img->volname); - notify(RUN, RECOVERY_NO_ERROR, sbuf); + notify(RUN, RECOVERY_NO_ERROR, INFOLEVEL, sbuf); TRACE("Updating UBI : %s %lld\n", img->fname, img->size); diff --git a/include/util.h b/include/util.h index cc0f465..24ec127 100644 --- a/include/util.h +++ b/include/util.h @@ -70,7 +70,7 @@ struct installer { char info[2048]; /* info */ }; -typedef void (*notifier) (RECOVERY_STATUS status, int level, const char *msg); +typedef void (*notifier) (RECOVERY_STATUS status, int error, int level, const char *msg); #define swupdate_notify(status, format, level, arg...) do { \ if (loglevel >= level) { \ @@ -86,11 +86,11 @@ typedef void (*notifier) (RECOVERY_STATUS status, int level, const char *msg); else \ snprintf(tmpbuf, sizeof(tmpbuf), \ "ERROR : " format, ## arg); \ - notify(FAILURE, 0, tmpbuf); \ + notify(FAILURE, 0, level, tmpbuf); \ } else {\ snprintf(tmpbuf, sizeof(tmpbuf), \ "[%s] : " format, __func__, ## arg); \ - notify(RUN, RECOVERY_NO_ERROR, tmpbuf); \ + notify(RUN, RECOVERY_NO_ERROR, level, tmpbuf); \ } \ } \ } while(0) @@ -155,7 +155,7 @@ off_t extract_next_file(int fd, int fdout, off_t start, int compressed, int openfileoutput(const char *filename); int register_notifier(notifier client); -void notify(RECOVERY_STATUS status, int level, const char *msg); +void notify(RECOVERY_STATUS status, int error, int level, const char *msg); void notify_init(void); int syslog_init(void); diff --git a/suricatta/server_hawkbit.c b/suricatta/server_hawkbit.c index 243db4f..1b0e600 100644 --- a/suricatta/server_hawkbit.c +++ b/suricatta/server_hawkbit.c @@ -301,9 +301,9 @@ static void check_action_changed(int action_id, const char *update_action) if (ENOMEM_ASPRINTF == asprintf(¬ifybuf, "{ \"id\" : \"%d\", \"update\" : \"%s\"}", action_id, server_hawkbit.update_action)) { - notify(SUBPROCESS, CHANGE, "Update type changed by server"); + notify(SUBPROCESS, CHANGE, DEBUGLEVEL, "Update type changed by server"); } else { - notify(SUBPROCESS, CHANGE, notifybuf); + notify(SUBPROCESS, CHANGE, DEBUGLEVEL, notifybuf); free(notifybuf); } } @@ -406,9 +406,9 @@ cleanup: if (ENOMEM_ASPRINTF == asprintf(¬ifybuf, "{ \"id\" : \"%d\", \"stopId\" : \"%d\"}", action_id, stop_id)) { - notify(SUBPROCESS, CANCELUPDATE, "Update cancelled"); + notify(SUBPROCESS, CANCELUPDATE, INFOLEVEL, "Update cancelled"); } else { - notify(SUBPROCESS, CANCELUPDATE, notifybuf); + notify(SUBPROCESS, CANCELUPDATE, INFOLEVEL, notifybuf); free(notifybuf); }