mirror of
https://github.com/palera1n/palera1n.git
synced 2026-10-23 18:49:48 +02:00
Revert "remove -P option"
This reverts commit fe6e4919b9bb3f9163303e5ca5cbde9d6ac47717.
This commit is contained in:
1 parent
d0347812a7
commit
cd80b66f28
6 files changed
+95
-155
No files matched your search
@@ -1,77 +0,0 @@
|
||||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
#include <pthread.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "ANSI-color-codes.h"
|
||||
#include "common.h"
|
||||
|
||||
int p1_log(log_level_t loglevel, const char *fname, int lineno, const char *fxname, char *__restrict format, ...)
|
||||
{
|
||||
if (verbose >= 5) fprintf(stderr, "p1_log: loglevel %d from %s:%d:%s()\n", loglevel, fname, lineno, fxname);
|
||||
int ret = 0;
|
||||
char type[0x10];
|
||||
char colour[0x10];
|
||||
char colour_bold[0x10];
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
if (verbose < (loglevel - 3) && loglevel > LOG_INFO) {
|
||||
if (verbose >= 5) fprintf(stderr, "p1_log: hid log with high log level (%d < %d)\n", verbose, loglevel - 3);
|
||||
return 0;
|
||||
}
|
||||
switch (loglevel) {
|
||||
case LOG_FATAL:
|
||||
snprintf(type, 0x10, "%s", "!");
|
||||
snprintf(colour, 0x10, "%s", RED);
|
||||
snprintf(colour_bold, 0x10, "%s", BRED);
|
||||
break;
|
||||
case LOG_ERROR:
|
||||
snprintf(type, 0x10, "%s", "Error");
|
||||
snprintf(colour, 0x10, "%s", RED);
|
||||
snprintf(colour_bold, 0x10, "%s", BRED);
|
||||
break;
|
||||
case LOG_WARNING:
|
||||
snprintf(type, 0x10, "%s", "Warning");
|
||||
snprintf(colour, 0x10, "%s", YEL);
|
||||
snprintf(colour_bold, 0x10, "%s", BYEL);
|
||||
break;
|
||||
case LOG_INFO:
|
||||
snprintf(type, 0x10, "%s", "Info");
|
||||
snprintf(colour, 0x10, "%s", CYN);
|
||||
snprintf(colour_bold, 0x10, "%s", BCYN);
|
||||
break;
|
||||
default:
|
||||
assert(loglevel >= 0);
|
||||
snprintf(type, 0x10, "%s", "Verbose");
|
||||
snprintf(colour, 0x10, "%s", WHT);
|
||||
snprintf(colour_bold, 0x10, "%s", BWHT);
|
||||
break;
|
||||
}
|
||||
pthread_mutex_lock(&log_mutex);
|
||||
char timestring[0x80];
|
||||
time_t curtime;
|
||||
time(&curtime);
|
||||
struct tm* timeinfo = localtime(&curtime);
|
||||
snprintf(timestring, 0x80, "%s[%s%02d/%02d/%d %02d:%02d:%02d%s]", CRESET, HBLK, timeinfo->tm_mon + 1, timeinfo->tm_mday, timeinfo->tm_year - 100, timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec, CRESET);
|
||||
if (verbose >= 2) {
|
||||
printf("%s| - %s%s <%s> " CRESET "%s" HBLU "%s" CRESET ":" BLU "%d" CRESET ":" BMAG "%s()" CRESET ": \n%s| ----> ", colour_bold, timestring, colour_bold, type, WHT, fname, lineno, fxname, colour_bold);
|
||||
} else {
|
||||
printf(" - %s %s<%s>%s: ", timestring, colour_bold, type, CRESET);
|
||||
}
|
||||
printf("%s", colour);
|
||||
ret = vprintf(format, args);
|
||||
va_end(args);
|
||||
|
||||
if (verbose < 2)
|
||||
printf(CRESET "\n");
|
||||
else {
|
||||
printf("\n%s-%s\n", colour, CRESET);
|
||||
}
|
||||
|
||||
fflush(stdout);
|
||||
pthread_mutex_unlock(&log_mutex);
|
||||
return ret;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user