From 44e68414b9ee857a783bdea90bf8b3b1b791f4c8 Mon Sep 17 00:00:00 2001 From: ngn Date: Fri, 19 Jul 2024 22:57:46 +0300 Subject: [PATCH] update: better colored logging --- locale/tr/LC_MESSAGES/pooler.po | 41 +++++++++------------------------ src/cmd/install.c | 16 ++++++------- src/cmd/list.c | 4 ++-- src/cmd/remove.c | 12 +++++----- src/cmd/sync.c | 2 +- src/cmd/update.c | 18 +++++++-------- src/log.c | 2 +- 7 files changed, 38 insertions(+), 57 deletions(-) diff --git a/locale/tr/LC_MESSAGES/pooler.po b/locale/tr/LC_MESSAGES/pooler.po index b5eb709..297ab0f 100644 --- a/locale/tr/LC_MESSAGES/pooler.po +++ b/locale/tr/LC_MESSAGES/pooler.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-07-19 22:32+0300\n" +"POT-Creation-Date: 2024-07-19 22:56+0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -242,14 +242,9 @@ msgstr "Havuzları sekronize etmek başarısız oldu: %s" msgid "Nothing to do (no packages to install)" msgstr "" -#: src/cmd/install.c:80 src/cmd/remove.c:67 src/cmd/update.c:50 -#, c-format -msgid "Following %d package will be " -msgstr "" - -#: src/cmd/install.c:82 src/cmd/remove.c:69 src/cmd/update.c:52 -#, c-format -msgid "Following %d packages will be " +#: src/cmd/install.c:80 src/cmd/install.c:82 src/cmd/remove.c:67 +#: src/cmd/remove.c:69 src/cmd/update.c:50 src/cmd/update.c:52 +msgid "Following " msgstr "" #: src/cmd/install.c:88 src/cmd/remove.c:76 @@ -264,9 +259,9 @@ msgstr "" msgid "Operation cancelled" msgstr "" -#: src/cmd/install.c:96 src/cmd/update.c:69 -#, c-format -msgid "(%d/%d) Downloading " +#: src/cmd/install.c:96 src/cmd/install.c:111 src/cmd/remove.c:85 +#: src/cmd/update.c:69 src/cmd/update.c:78 src/cmd/update.c:87 +msgid "(" msgstr "" #: src/cmd/install.c:102 src/cmd/update.c:74 @@ -274,24 +269,17 @@ msgstr "" msgid "Failed to download " msgstr "Havuzları sekronize etmek başarısız oldu: %s" -#: src/cmd/install.c:111 src/cmd/update.c:87 -#, c-format -msgid "(%d/%d) Installing " -msgstr "" - #: src/cmd/install.c:117 src/cmd/update.c:92 #, fuzzy msgid "Failed to install " msgstr "Havuzları sekronize etmek başarısız oldu: %s" #: src/cmd/install.c:123 -#, c-format -msgid "Installed %d package" +msgid "Installed " msgstr "" #: src/cmd/install.c:123 -#, c-format -msgid "Installed all of the %d packages" +msgid "Installed all of the " msgstr "" #: src/cmd/list.c:27 @@ -315,24 +303,17 @@ msgstr "Havuzları sekronize etmek başarısız oldu: %s" msgid "Nothing to do (no packages to remove)" msgstr "" -#: src/cmd/remove.c:85 src/cmd/update.c:78 -#, c-format -msgid "(%d/%d) Removing " -msgstr "" - #: src/cmd/remove.c:91 src/cmd/update.c:83 #, fuzzy msgid "Failed to remove " msgstr "Havuzları sekronize etmek başarısız oldu: %s" #: src/cmd/remove.c:97 -#, c-format -msgid "Removed %d package" +msgid "Removed " msgstr "" #: src/cmd/remove.c:97 -#, c-format -msgid "Removed all of the %d packages" +msgid "Removed all of the " msgstr "" #: src/cmd/sync.c:19 diff --git a/src/cmd/install.c b/src/cmd/install.c index 0f4b2f1..63068a0 100644 --- a/src/cmd/install.c +++ b/src/cmd/install.c @@ -56,7 +56,7 @@ bool cmd_install(lm_ctx_t *ctx, config_t *config, args_t *args){ } if(lm_ctx_database_is_installed(ctx, pkg, true)){ - error(_("Package "FG_BOLD"%s"FG_RESET" ("FG_BLUE"%s"FG_RESET") is already installed"), name, pkg->version); + error(_("Package "FG_BOLD"%s"FG_RESET"_"FG_GREEN"%s"FG_RESET" is already installed"), name, pkg->version); goto end; } @@ -77,9 +77,9 @@ bool cmd_install(lm_ctx_t *ctx, config_t *config, args_t *args){ size_to_human(ssize, size); if(list->count == 1) - info(_("Following %d package will be "FG_BOLD"INSTALLED:"FG_RESET), list->count); + info(_("Following "FG_BOLD"%d"FG_RESET" package will be "FG_BOLD"INSTALLED:"FG_RESET), list->count); else - info(_("Following %d packages will be "FG_BOLD"INSTALLED:"FG_RESET), list->count); + info(_("Following "FG_BOLD"%d"FG_RESET" packages will be "FG_BOLD"INSTALLED:"FG_RESET), list->count); while((pkg = lm_ctx_resolve_next(list)) != NULL) package_list(pkg, &save, 0); @@ -93,13 +93,13 @@ bool cmd_install(lm_ctx_t *ctx, config_t *config, args_t *args){ // download resolved packages while((pkg = lm_ctx_resolve_next(list)) != NULL){ - info(_("(%d/%d) Downloading "FG_BOLD"%s"FG_RESET" ("FG_BOLD FG_BLUE"%s"FG_RESET")"), ++current, list->count, pkg->name, pkg->version); + info(_("("FG_BOLD"%d"FG_RESET"/"FG_BOLD"%d"FG_RESET") Downloading "FG_BOLD"%s"FG_RESET"_"FG_BOLD FG_GREEN"%s"), ++current, list->count, pkg->name, pkg->version); r = lm_ctx_download(ctx, pkg, cmd_download_callback, NULL); bar_free(); if(!r){ - error(_("Failed to download "FG_BOLD"%s"FG_RESET": %s"), pkg->name, lm_strerror()); + error(_("Failed to download "FG_BOLD"%s"FG_RESET"_"FG_BOLD FG_GREEN"%s"FG_RESET": %s"), pkg->name, pkg->version, lm_strerror()); goto end; } } @@ -108,19 +108,19 @@ bool cmd_install(lm_ctx_t *ctx, config_t *config, args_t *args){ // install resolved packages while((pkg = lm_ctx_resolve_next(list)) != NULL){ - info(_("(%d/%d) Installing "FG_BOLD"%s"FG_RESET" ("FG_BOLD FG_BLUE"%s"FG_RESET")"), ++current, list->count, pkg->name, pkg->version); + info(_("("FG_BOLD"%d"FG_RESET"/"FG_BOLD"%d"FG_RESET") Installing "FG_BOLD"%s"FG_RESET"_"FG_BOLD FG_GREEN"%s"), ++current, list->count, pkg->name, pkg->version); r = lm_ctx_install(ctx, pkg, cmd_install_callback, NULL); bar_free(); if(!r){ - error(_("Failed to install "FG_BOLD"%s"FG_RESET": %s"), pkg->name, lm_strerror()); + error(_("Failed to install "FG_BOLD"%s"FG_RESET"_"FG_BOLD FG_GREEN"%s"FG_RESET": %s"), pkg->name, pkg->version, lm_strerror()); goto end; } } if(current == list->count){ - success(list->count == 1 ? _("Installed %d package") : _("Installed all of the %d packages"), list->count); + success(list->count == 1 ? _("Installed "FG_BOLD"%d"FG_RESET" package") : _("Installed all of the "FG_BOLD"%d"FG_RESET" packages"), list->count); ret = true; } diff --git a/src/cmd/list.c b/src/cmd/list.c index eed4c6d..1e01a8e 100644 --- a/src/cmd/list.c +++ b/src/cmd/list.c @@ -41,9 +41,9 @@ bool cmd_list(lm_ctx_t *ctx, config_t *config, args_t *args){ } if(args_get_bool(args, "desc")) - printf(FG_BOLD"%s"FG_RESET" ("FG_BOLD FG_BLUE"%s"FG_RESET"): %s\n", pkg.name, pkg.version, pkg.desc); + printf(FG_BOLD"%s"FG_RESET"_"FG_BOLD FG_GREEN"%s"FG_RESET": %s\n", pkg.name, pkg.version, pkg.desc); else - printf(FG_BOLD"%s"FG_RESET" ("FG_BOLD FG_BLUE"%s"FG_RESET")\n", pkg.name, pkg.version); + printf(FG_BOLD"%s"FG_RESET"_"FG_BOLD FG_GREEN"%s"FG_RESET"\n", pkg.name, pkg.version); } lm_ctx_database_next_free(ctx, &pkg); diff --git a/src/cmd/remove.c b/src/cmd/remove.c index 427024f..80f2866 100644 --- a/src/cmd/remove.c +++ b/src/cmd/remove.c @@ -49,7 +49,7 @@ bool cmd_remove(lm_ctx_t *ctx, config_t *config, args_t *args){ } if(!lm_ctx_removeable(ctx, &pkgs[count-1])){ - error(_("Cannot remove "FG_BOLD"%s"FG_RESET" ("FG_BOLD FG_BLUE"%s"FG_RESET"): %s"), pkgs[count-1].name, pkgs[count-1].version, lm_strerror()); + error(_("Cannot remove "FG_BOLD"%s"FG_RESET"_"FG_BOLD FG_GREEN"%s"FG_RESET": %s"), pkgs[count-1].name, pkgs[count-1].version, lm_strerror()); goto end; } @@ -64,9 +64,9 @@ bool cmd_remove(lm_ctx_t *ctx, config_t *config, args_t *args){ size_to_human(ssize, size); if(count == 1) - info(_("Following %d package will be "FG_BOLD"REMOVED:"FG_RESET), count); + info(_("Following "FG_BOLD"%d"FG_RESET" package will be "FG_BOLD"REMOVED:"FG_RESET), count); else - info(_("Following %d packages will be "FG_BOLD"REMOVED:"FG_RESET), count); + info(_("Following "FG_BOLD"%d"FG_RESET" packages will be "FG_BOLD"REMOVED:"FG_RESET), count); // list all the packages for(int i = 0; i < count; i++) @@ -82,19 +82,19 @@ bool cmd_remove(lm_ctx_t *ctx, config_t *config, args_t *args){ for(int i = 0; i < count; i++){ lm_pkg_t *cur = &pkgs[i]; - info(_("(%d/%d) Removing "FG_BOLD"%s"FG_RESET" ("FG_BOLD FG_BLUE"%s"FG_RESET")"), ++current, count, cur->name, cur->version); + info(_("("FG_BOLD"%d"FG_RESET"/"FG_BOLD"%d"FG_RESET") Removing "FG_BOLD"%s"FG_RESET"_"FG_BOLD FG_GREEN"%s"FG_RESET), ++current, count, cur->name, cur->version); r = lm_ctx_remove(ctx, cur, cmd_remove_callback, NULL); bar_free(); if(!r){ - error(_("Failed to remove "FG_BOLD"%s"FG_RESET": %s"), cur->name, lm_strerror()); + error(_("Failed to remove "FG_BOLD"%s"FG_RESET"_"FG_BOLD FG_GREEN"%s"FG_RESET": %s"), cur->name, cur->version, lm_strerror()); goto end; } } if(current == count){ - success(count == 1 ? _("Removed %d package") : _("Removed all of the %d packages"), count); + success(count == 1 ? _("Removed "FG_BOLD"%d"FG_RESET" package") : _("Removed all of the "FG_BOLD"%d"FG_RESET" packages"), count); ret = true; } diff --git a/src/cmd/sync.c b/src/cmd/sync.c index 7b092ec..9f6f0b0 100644 --- a/src/cmd/sync.c +++ b/src/cmd/sync.c @@ -55,7 +55,7 @@ bool cmd_sync(lm_ctx_t *ctx, config_t *config, args_t *args){ goto end; } - info(_("Synced "FG_BOLD"%d/%d"FG_RESET" pools"), sycned, config->pool_count); + info(_("Synced "FG_BOLD"%d"FG_RESET"/"FG_BOLD"%d"FG_RESET" pools"), sycned, config->pool_count); ret = true; end: diff --git a/src/cmd/update.c b/src/cmd/update.c index 7039a1a..8a2c69f 100644 --- a/src/cmd/update.c +++ b/src/cmd/update.c @@ -47,9 +47,9 @@ bool cmd_update(lm_ctx_t *ctx, config_t *config, args_t *args){ } if(list->count == 1) - info(_("Following %d package will be "FG_BOLD"UPDATED:"FG_RESET), list->count); + info(_("Following "FG_BOLD"%d"FG_RESET" package will be "FG_BOLD"UPDATED:"FG_RESET), list->count); else - info(_("Following %d packages will be "FG_BOLD"UPDATED:"FG_RESET), list->count); + info(_("Following "FG_BOLD"%d"FG_RESET" packages will be "FG_BOLD"UPDATED:"FG_RESET), list->count); while((old = lm_ctx_update_list_next(list)) != NULL) package_list(old, &save, 0); @@ -62,34 +62,34 @@ bool cmd_update(lm_ctx_t *ctx, config_t *config, args_t *args){ while((old = lm_ctx_update_list_next(list)) != NULL){ if((new = lm_ctx_update(ctx, old)) == NULL){ - error(_("Failed to update "FG_BOLD"%s"FG_RESET": %s"), old->name, lm_strerror()); + error(_("Failed to update "FG_BOLD"%s"FG_RESET"_"FG_BOLD FG_GREEN"%s"FG_RESET": %s"), old->name, old->version, lm_strerror()); goto end; } - info(_("(%d/%d) Downloading "FG_BOLD"%s"FG_RESET" ("FG_BOLD FG_BLUE"%s"FG_RESET")"), ++current, list->count, new->name, new->version); + info(_("("FG_BOLD"%d"FG_RESET"/"FG_BOLD"%d"FG_RESET") Downloading "FG_BOLD"%s"FG_RESET"_"FG_BOLD FG_GREEN"%s"), ++current, list->count, new->name, new->version); r = lm_ctx_download(ctx, new, cmd_update_download_callback, NULL); bar_free(); if(!r){ - error(_("Failed to download "FG_BOLD"%s"FG_RESET" ("FG_BOLD FG_BLUE"%s"FG_RESET"): %s"), new->name, new->version, lm_strerror()); + error(_("Failed to download "FG_BOLD"%s"FG_RESET"_"FG_BOLD FG_GREEN"%s"FG_RESET": %s"), new->name, new->version, lm_strerror()); goto end; } - info(_("(%d/%d) Removing "FG_BOLD"%s"FG_RESET" ("FG_BOLD FG_BLUE"%s"FG_RESET")"), current, list->count, old->name, old->version); + info(_("("FG_BOLD"%d"FG_RESET"/"FG_BOLD"%d"FG_RESET") Removing "FG_BOLD"%s"FG_RESET"_"FG_BOLD FG_GREEN"%s"), current, list->count, old->name, old->version); r = lm_ctx_remove(ctx, old, cmd_update_callback, NULL); bar_free(); if(!r){ - error(_("Failed to remove "FG_BOLD"%s"FG_RESET" ("FG_BOLD FG_BLUE"%s"FG_RESET"): %s"), old->name, old->version, lm_strerror()); + error(_("Failed to remove "FG_BOLD"%s"FG_RESET"_"FG_BOLD FG_GREEN"%s"FG_RESET": %s"), old->name, old->version, lm_strerror()); goto end; } - info(_("(%d/%d) Installing "FG_BOLD"%s"FG_RESET" ("FG_BOLD FG_BLUE"%s"FG_RESET")"), current, list->count, new->name, new->version); + info(_("("FG_BOLD"%d"FG_RESET"/"FG_BOLD"%d"FG_RESET") Installing "FG_BOLD"%s"FG_RESET"_"FG_BOLD FG_GREEN"%s"), current, list->count, new->name, new->version); r = lm_ctx_install(ctx, new, cmd_update_callback, NULL); bar_free(); if(!r){ - error(_("Failed to install "FG_BOLD"%s"FG_RESET" ("FG_BOLD FG_BLUE"%s"FG_RESET"): %s"), new->name, new->version, lm_strerror()); + error(_("Failed to install "FG_BOLD"%s"FG_RESET"_"FG_BOLD FG_GREEN"%s"FG_RESET": %s"), new->name, new->version, lm_strerror()); goto end; } } diff --git a/src/log.c b/src/log.c index 6ba3393..4501abb 100644 --- a/src/log.c +++ b/src/log.c @@ -39,7 +39,7 @@ void package_list(lm_pkg_t *pkg, ssize_t *save, ssize_t max) { } end: - printf(FG_BOLD "%s " FG_BLUE "%s" FG_RESET, pkg->name, pkg->version); + printf(FG_BOLD "%s" FG_RESET "_" FG_BOLD FG_GREEN "%s", pkg->name, pkg->version); printf(" "); }