update: better colored logging

This commit is contained in:
ngn 2024-07-19 22:57:46 +03:00
parent afb4122f97
commit 44e68414b9
7 changed files with 38 additions and 57 deletions

View File

@ -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 <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\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

View File

@ -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;
}

View File

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

View File

@ -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;
}

View File

@ -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:

View File

@ -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;
}
}

View File

@ -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(" ");
}