Better Logging For Commands

Better messages for the commands
main
lomna-dev 1 year ago
parent 617b8f0594
commit 1c3ec2c102

@ -226,7 +226,15 @@ void TASKS_do_all_tasks(){
while(cll != NULL){ while(cll != NULL){
char *cmd = cll->data; char *cmd = cll->data;
printf("+ %s\n", cmd); printf("+ %s\n", cmd);
system(cmd); int r_code = system(cmd);
if(errno != 0 && r_code == -1)
perror(cmd);
if(r_code != EXIT_SUCCESS)
printf("[✗] FAILED COMMAND : %s\n[✗] C system() function return value : %d\n", cmd, r_code);
else
printf("[✔] COMPLETED COMMAND : %s\n[✔] C system() function return value : %d\n", cmd, r_code);
cll = cll->next; cll = cll->next;
} }
printf("\n"); printf("\n");
@ -265,7 +273,7 @@ void TASKS_do_tasks_ifchange(char *filename){
icll = icll->next; icll = icll->next;
} }
if(map == NULL) skip_task = false; if(map == NULL || tasks[i].ifchange == NULL) skip_task = false;
if(skip_task) continue; if(skip_task) continue;
printf("[*] EXECUTING TASK : %s\n", tasks[i].name); printf("[*] EXECUTING TASK : %s\n", tasks[i].name);
@ -273,13 +281,24 @@ void TASKS_do_tasks_ifchange(char *filename){
while(cll != NULL){ while(cll != NULL){
char *cmd = cll->data; char *cmd = cll->data;
printf("+ %s\n", cmd); printf("+ %s\n", cmd);
system(cmd); int r_code = system(cmd);
// Don't know if this is cross platform, but according to Linux man-pages 6.03
// If a child process could not be created, or its status could not be retrieved, the return value is -1 and errno is set to indicate the error.
if(errno != 0 && r_code == -1)
perror(cmd);
if(r_code != EXIT_SUCCESS)
printf("[✗] FAILED COMMAND : %s\n[✗] C system() function return value : %d\n", cmd, r_code);
else
printf("[✔] COMPLETED COMMAND : %s\n[✔] C system() function return value : %d\n", cmd, r_code);
cll = cll->next; cll = cll->next;
} }
printf("\n"); printf("\n");
} }
if(new_map != NULL){ if(new_map != NULL){
printf("\n<-> <-> <-> <-> <-> <-> <-> <-> <-> <-> <-> <-> <-> <-> <-> <->\n");
printf("\nSaving file named %s with sha1 values\n", binary_filename); printf("\nSaving file named %s with sha1 values\n", binary_filename);
LookupList_print(new_map); LookupList_print(new_map);
LookupList_store(new_map, binary_filename); LookupList_store(new_map, binary_filename);
@ -291,6 +310,7 @@ void TASKS_do_tasks_ifchange(char *filename){
} }
int main(int argc, char *argv[]){ int main(int argc, char *argv[]){
errno = 0;
char *tasks_file = "main.tsk"; char *tasks_file = "main.tsk";
if(argc > 1){ if(argc > 1){

Loading…
Cancel
Save