diff --git a/main.c b/main.c index ce812df..0cf3919 100644 --- a/main.c +++ b/main.c @@ -15,12 +15,12 @@ int main(void) printf("Log creation failed\n"); return 1; } - printx(INFO, "Tweekd starting\n"); - printx(DEBUG, "Creating processes\n"); + printx(INFO, MAIN, "Tweekd starting\n"); + printx(DEBUG, MAIN, "Creating processes\n"); displayUI(); ret = pthread_create(&tUI, NULL, drawUI, NULL); - printx(DEBUG, "UI Started ID %08x ret %d\n", tUI, ret); - printx(INFO, "Initializing NFC"); + printx(DEBUG, MAIN, "UI Started ID %08x ret %d\n", tUI, ret); + printx(INFO, MAIN, "Initializing NFC"); //pthread_create(&tNFC, NULL, pthread_join(tUI, NULL); closeLog(); diff --git a/nfc.c b/nfc.c new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/nfc.c diff --git a/nfc.h b/nfc.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/nfc.h diff --git a/printx.c b/printx.c index 62cfb2c..e582683 100644 --- a/printx.c +++ b/printx.c @@ -13,6 +13,7 @@ FILE* logfile = NULL; char s_color[4][12] = {"\x1b[01;31m", "\x1b[01;33m", "\x1b[01;32m", "\x1b[01;36m"}; +char f_name[5][5] = {"MAIN", "UI ", "NFC ", "HVC ", "BUS "}; void removeCharFromString(char c, char *str) { @@ -48,7 +49,7 @@ void closeLog() fclose(logfile); } -void printx(severity s, char* str, ...) +void printx(severity s, msgfrom from, char* str, ...) { char buffer1[MAX_BUFFER]; char buffer2[MAX_BUFFER]; @@ -56,7 +57,7 @@ void printx(severity s, char* str, ...) va_start(arglist, str); vsprintf(buffer1, str, arglist); fprintf(logfile, buffer1); - sprintf(buffer2, "%s%s%s", s_color[s], buffer1, S_RESET); + sprintf(buffer2, "[%s] : %s%s%s", f_name[from], s_color[s], buffer1, S_RESET); removeCharFromString('\n', buffer2); addToLog(buffer2); va_end(arglist); diff --git a/printx.h b/printx.h index bb9ac69..71379a7 100644 --- a/printx.h +++ b/printx.h @@ -8,8 +8,13 @@ typedef enum ERROR, WARNING, INFO, DEBUG }severity; +typedef enum +{ + MAIN, UI, NFC, HVC, BUS +}msgfrom; + bool initLog(); -void printx(severity, char*, ...); +void printx(severity, msgfrom, char*, ...); void closeLog(); #endif diff --git a/ui.c b/ui.c index d732182..a3fcc6e 100644 --- a/ui.c +++ b/ui.c @@ -8,7 +8,7 @@ #define TIME_LENGTH 24 #define HEADER_TEXT_LENGTH 24 #define LOG_LINES 25 -#define LOG_LENGTH 69 +#define LOG_LENGTH 82 #define IPS 20 #define SCREEN_TIME 1000000/IPS #define SPACES " " @@ -64,33 +64,11 @@ void addToLog(char* newStr) char* fillLogWithSpaces(char* buf, char* text) { -/* - char tmpretlog[LOG_LENGTH]; - strncpy(tmpretlog, text, LOG_LENGTH); - if(strlen(text) > 0) - while((strlen(tmpretlog)-12) < LOG_LENGTH) - strcat(tmpretlog, " "); - else - while(strlen(tmpretlog) < LOG_LENGTH) - strcat(tmpretlog, " "); - -// int j; -// printf("J val\n"); -// printf("%d\n", j); - for(int j=0; j 0) - while((strlen(buf)-12) < LOG_LENGTH) - strcat(buf, " "); + strncat(buf, SPACES, LOG_LENGTH-strlen(buf)-1); else - while(strlen(buf) < LOG_LENGTH) - strcat(buf, " "); - */ - //strncat(buf, SPACES, LOG_LENGTH-strlen(buf)); + strncat(buf, SPACES, LOG_LENGTH-strlen(buf)-1-12); return buf; } -- libgit2 0.21.2