Message ID | 20220527045948.3672022-2-dominique.martinet@atmark-techno.com |
---|---|
State | RFC |
Headers | show |
Series | Allow scripts to write INFO and WARN messages | expand |
Hi Dominique, On 27.05.22 06:59, Dominique Martinet wrote: > I'd like to use info for some update messages which would otherwise be lost > in trace. > > This commit makes a sample swupdate run output go from: > --- > SWUpdate v2022.05.0 > > Licensed under GPLv2. See source distribution for detailed copyright notices. > > [INFO ] : SWUPDATE running : [print_registered_bootloaders] : Registered bootloaders: > [INFO ] : SWUPDATE running : [print_registered_bootloaders] : none loaded. > [INFO ] : SWUPDATE running : [main] : Using default bootloader interface: none > [INFO ] : SWUPDATE running : [lua_handlers_init] : External Lua handler(s) not found. > [INFO ] : SWUPDATE running : [main] : Running on iot-g4-es1 Revision at1 > [INFO ] : SWUPDATE running : [print_registered_handlers] : Registered handlers: > [INFO ] : SWUPDATE running : [print_registered_handlers] : postinstall > [INFO ] : SWUPDATE running : [print_registered_handlers] : preinstall > [INFO ] : SWUPDATE running : [print_registered_handlers] : shellscript > [INFO ] : SWUPDATE running : [print_registered_handlers] : readback > [INFO ] : SWUPDATE running : [print_registered_handlers] : rawcopy > [INFO ] : SWUPDATE running : [print_registered_handlers] : rawfile > [INFO ] : SWUPDATE running : [print_registered_handlers] : raw > [INFO ] : SWUPDATE running : [print_registered_handlers] : lua > [INFO ] : SWUPDATE running : [print_registered_handlers] : toggleboot > [INFO ] : SWUPDATE running : [print_registered_handlers] : diskpart > [INFO ] : SWUPDATE running : [print_registered_handlers] : bootloader > [INFO ] : SWUPDATE running : [print_registered_handlers] : uboot > [INFO ] : SWUPDATE running : [print_registered_handlers] : tar > [INFO ] : SWUPDATE running : [print_registered_handlers] : archive > [INFO ] : SWUPDATE running : [print_registered_handlers] : dummy > [INFO ] : SWUPDATE running : [print_registered_handlers] : exec > [INFO ] : SWUPDATE started : Software Update started ! > [ERROR] : SWUPDATE failed [0] ERROR : error > [INFO ] : SWUPDATE running : [read_lines_notify] : info > [WARN ] : SWUPDATE running : [read_lines_notify] : warn > [INFO ] : SWUPDATE running : Installation in progress > [INFO ] : SWUPDATE successful ! SWUPDATE successful ! > [INFO ] : No SWUPDATE running : Waiting for requests... > [INFO ] : SWUPDATE running : [endupdate] : SWUpdate was successful ! > --- > To: > --- > SWUpdate v2022.05.0 > > Licensed under GPLv2. See source distribution for detailed copyright notices. > > [INFO ] : SWUPDATE started : Software Update started ! > [ERROR] : SWUPDATE failed [0] ERROR : error > [INFO ] : SWUPDATE running : [read_lines_notify] : info > [WARN ] : SWUPDATE running : [read_lines_notify] : warn > [INFO ] : SWUPDATE running : Installation in progress > [INFO ] : SWUPDATE successful ! SWUPDATE successful ! > [INFO ] : No SWUPDATE running : Waiting for requests... > --- > This helps just in case SWUpdate is steadily stop and restarted, but this is not the way SWUpdate was thought. SWUpdate starts as daemon, and it is fine to check due to the dynamic way to load handlers, if they were found and initialized. So I will stick with current implementation. Best regards, Stefano > Where the three messages (error/info/warn) in the middle come from > my swu image > > Signed-off-by: Dominique Martinet <dominique.martinet@atmark-techno.com> > --- > core/bootloader.c | 4 ++-- > core/handler.c | 4 ++-- > core/install_from_file.c | 3 ++- > core/swupdate.c | 6 +++--- > corelib/lua_interface.c | 4 ++-- > 5 files changed, 11 insertions(+), 10 deletions(-) > > diff --git a/core/bootloader.c b/core/bootloader.c > index f34cb41443a9..89632f3e0524 100644 > --- a/core/bootloader.c > +++ b/core/bootloader.c > @@ -62,9 +62,9 @@ const char* get_bootloader(void) > > void print_registered_bootloaders(void) > { > - INFO("Registered bootloaders:"); > + TRACE("Registered bootloaders:"); > for (unsigned int i = 0; i < num_available; i++) { > - INFO("\t%s\t%s", available[i].name, > + TRACE("\t%s\t%s", available[i].name, > available[i].funcs == NULL ? "shared lib not found." > : "loaded."); > } > diff --git a/core/handler.c b/core/handler.c > index 0a713cf497ce..6b1316ed7eb2 100644 > --- a/core/handler.c > +++ b/core/handler.c > @@ -56,9 +56,9 @@ void print_registered_handlers(void) > if (!nr_installers) > return; > > - INFO("Registered handlers:"); > + TRACE("Registered handlers:"); > for (i = 0; i < nr_installers; i++) { > - INFO("\t%s", supported_types[i].desc); > + TRACE("\t%s", supported_types[i].desc); > } > } > > diff --git a/core/install_from_file.c b/core/install_from_file.c > index b49f624c9ae7..220a2e2e63a2 100644 > --- a/core/install_from_file.c > +++ b/core/install_from_file.c > @@ -51,7 +51,8 @@ static int endupdate(RECOVERY_STATUS status) > { > end_status = (status == SUCCESS) ? EXIT_SUCCESS : EXIT_FAILURE; > > - INFO("SWUpdate %s\n", > + /* note this is also printed in network initializer thread */ > + TRACE("SWUpdate %s\n", > status == FAILURE ? "*failed* !" : > "was successful !"); > > diff --git a/core/swupdate.c b/core/swupdate.c > index 3c9c8cb6a100..f3ec47f62380 100644 > --- a/core/swupdate.c > +++ b/core/swupdate.c > @@ -781,9 +781,9 @@ int main(int argc, char **argv) > INFO("Or chose another bootloader interface by supplying -B <loader>."); > exit(EXIT_FAILURE); > } > - INFO("Using default bootloader interface: " PREPROCVALUE(BOOTLOADER_DEFAULT)); > + TRACE("Using default bootloader interface: " PREPROCVALUE(BOOTLOADER_DEFAULT)); > } else { > - INFO("Using bootloader interface: %s", get_bootloader()); > + TRACE("Using bootloader interface: %s", get_bootloader()); > } > > /* > @@ -813,7 +813,7 @@ int main(int argc, char **argv) > lua_handlers_init(); > > if(!get_hw_revision(&swcfg.hw)) > - INFO("Running on %s Revision %s", swcfg.hw.boardname, swcfg.hw.revision); > + TRACE("Running on %s Revision %s", swcfg.hw.boardname, swcfg.hw.revision); > > print_registered_handlers(); > if (swcfg.syslog_enabled) { > diff --git a/corelib/lua_interface.c b/corelib/lua_interface.c > index dd1be9e5f548..6e7d68f43bc6 100644 > --- a/corelib/lua_interface.c > +++ b/corelib/lua_interface.c > @@ -1303,11 +1303,11 @@ int lua_handlers_init(void) > ret = luaL_dostring(gL, "require (\"swupdate_handlers\")"); > #endif > if (ret != 0) { > - INFO("%s Lua handler(s) not found.", location); > + TRACE("%s Lua handler(s) not found.", location); > lua_report_exception(gL); > lua_pop(gL, 1); > } else { > - INFO("%s Lua handler(s) found and loaded.", location); > + TRACE("%s Lua handler(s) found and loaded.", location); > } > } else { > WARN("Unable to register Lua context for callbacks");
diff --git a/core/bootloader.c b/core/bootloader.c index f34cb41443a9..89632f3e0524 100644 --- a/core/bootloader.c +++ b/core/bootloader.c @@ -62,9 +62,9 @@ const char* get_bootloader(void) void print_registered_bootloaders(void) { - INFO("Registered bootloaders:"); + TRACE("Registered bootloaders:"); for (unsigned int i = 0; i < num_available; i++) { - INFO("\t%s\t%s", available[i].name, + TRACE("\t%s\t%s", available[i].name, available[i].funcs == NULL ? "shared lib not found." : "loaded."); } diff --git a/core/handler.c b/core/handler.c index 0a713cf497ce..6b1316ed7eb2 100644 --- a/core/handler.c +++ b/core/handler.c @@ -56,9 +56,9 @@ void print_registered_handlers(void) if (!nr_installers) return; - INFO("Registered handlers:"); + TRACE("Registered handlers:"); for (i = 0; i < nr_installers; i++) { - INFO("\t%s", supported_types[i].desc); + TRACE("\t%s", supported_types[i].desc); } } diff --git a/core/install_from_file.c b/core/install_from_file.c index b49f624c9ae7..220a2e2e63a2 100644 --- a/core/install_from_file.c +++ b/core/install_from_file.c @@ -51,7 +51,8 @@ static int endupdate(RECOVERY_STATUS status) { end_status = (status == SUCCESS) ? EXIT_SUCCESS : EXIT_FAILURE; - INFO("SWUpdate %s\n", + /* note this is also printed in network initializer thread */ + TRACE("SWUpdate %s\n", status == FAILURE ? "*failed* !" : "was successful !"); diff --git a/core/swupdate.c b/core/swupdate.c index 3c9c8cb6a100..f3ec47f62380 100644 --- a/core/swupdate.c +++ b/core/swupdate.c @@ -781,9 +781,9 @@ int main(int argc, char **argv) INFO("Or chose another bootloader interface by supplying -B <loader>."); exit(EXIT_FAILURE); } - INFO("Using default bootloader interface: " PREPROCVALUE(BOOTLOADER_DEFAULT)); + TRACE("Using default bootloader interface: " PREPROCVALUE(BOOTLOADER_DEFAULT)); } else { - INFO("Using bootloader interface: %s", get_bootloader()); + TRACE("Using bootloader interface: %s", get_bootloader()); } /* @@ -813,7 +813,7 @@ int main(int argc, char **argv) lua_handlers_init(); if(!get_hw_revision(&swcfg.hw)) - INFO("Running on %s Revision %s", swcfg.hw.boardname, swcfg.hw.revision); + TRACE("Running on %s Revision %s", swcfg.hw.boardname, swcfg.hw.revision); print_registered_handlers(); if (swcfg.syslog_enabled) { diff --git a/corelib/lua_interface.c b/corelib/lua_interface.c index dd1be9e5f548..6e7d68f43bc6 100644 --- a/corelib/lua_interface.c +++ b/corelib/lua_interface.c @@ -1303,11 +1303,11 @@ int lua_handlers_init(void) ret = luaL_dostring(gL, "require (\"swupdate_handlers\")"); #endif if (ret != 0) { - INFO("%s Lua handler(s) not found.", location); + TRACE("%s Lua handler(s) not found.", location); lua_report_exception(gL); lua_pop(gL, 1); } else { - INFO("%s Lua handler(s) found and loaded.", location); + TRACE("%s Lua handler(s) found and loaded.", location); } } else { WARN("Unable to register Lua context for callbacks");
I'd like to use info for some update messages which would otherwise be lost in trace. This commit makes a sample swupdate run output go from: --- SWUpdate v2022.05.0 Licensed under GPLv2. See source distribution for detailed copyright notices. [INFO ] : SWUPDATE running : [print_registered_bootloaders] : Registered bootloaders: [INFO ] : SWUPDATE running : [print_registered_bootloaders] : none loaded. [INFO ] : SWUPDATE running : [main] : Using default bootloader interface: none [INFO ] : SWUPDATE running : [lua_handlers_init] : External Lua handler(s) not found. [INFO ] : SWUPDATE running : [main] : Running on iot-g4-es1 Revision at1 [INFO ] : SWUPDATE running : [print_registered_handlers] : Registered handlers: [INFO ] : SWUPDATE running : [print_registered_handlers] : postinstall [INFO ] : SWUPDATE running : [print_registered_handlers] : preinstall [INFO ] : SWUPDATE running : [print_registered_handlers] : shellscript [INFO ] : SWUPDATE running : [print_registered_handlers] : readback [INFO ] : SWUPDATE running : [print_registered_handlers] : rawcopy [INFO ] : SWUPDATE running : [print_registered_handlers] : rawfile [INFO ] : SWUPDATE running : [print_registered_handlers] : raw [INFO ] : SWUPDATE running : [print_registered_handlers] : lua [INFO ] : SWUPDATE running : [print_registered_handlers] : toggleboot [INFO ] : SWUPDATE running : [print_registered_handlers] : diskpart [INFO ] : SWUPDATE running : [print_registered_handlers] : bootloader [INFO ] : SWUPDATE running : [print_registered_handlers] : uboot [INFO ] : SWUPDATE running : [print_registered_handlers] : tar [INFO ] : SWUPDATE running : [print_registered_handlers] : archive [INFO ] : SWUPDATE running : [print_registered_handlers] : dummy [INFO ] : SWUPDATE running : [print_registered_handlers] : exec [INFO ] : SWUPDATE started : Software Update started ! [ERROR] : SWUPDATE failed [0] ERROR : error [INFO ] : SWUPDATE running : [read_lines_notify] : info [WARN ] : SWUPDATE running : [read_lines_notify] : warn [INFO ] : SWUPDATE running : Installation in progress [INFO ] : SWUPDATE successful ! SWUPDATE successful ! [INFO ] : No SWUPDATE running : Waiting for requests... [INFO ] : SWUPDATE running : [endupdate] : SWUpdate was successful ! --- To: --- SWUpdate v2022.05.0 Licensed under GPLv2. See source distribution for detailed copyright notices. [INFO ] : SWUPDATE started : Software Update started ! [ERROR] : SWUPDATE failed [0] ERROR : error [INFO ] : SWUPDATE running : [read_lines_notify] : info [WARN ] : SWUPDATE running : [read_lines_notify] : warn [INFO ] : SWUPDATE running : Installation in progress [INFO ] : SWUPDATE successful ! SWUPDATE successful ! [INFO ] : No SWUPDATE running : Waiting for requests... --- Where the three messages (error/info/warn) in the middle come from my swu image Signed-off-by: Dominique Martinet <dominique.martinet@atmark-techno.com> --- core/bootloader.c | 4 ++-- core/handler.c | 4 ++-- core/install_from_file.c | 3 ++- core/swupdate.c | 6 +++--- corelib/lua_interface.c | 4 ++-- 5 files changed, 11 insertions(+), 10 deletions(-)