diff options
author | Andreas Eversberg <jolly@eversberg.eu> | 2021-08-22 18:27:33 +0200 |
---|---|---|
committer | Andreas Eversberg <jolly@eversberg.eu> | 2021-09-17 16:33:29 +0200 |
commit | 80d911e5a649b4c9cf3bb506c766b1611a8e95aa (patch) | |
tree | e8b1b1f772beb029a2e25c1da71f085fdb9505f9 /src/libdebug | |
parent | 185db11ace44e70f93f3f27cfa439d984da17a01 (diff) |
Updated libs
Diffstat (limited to 'src/libdebug')
-rw-r--r-- | src/libdebug/debug.c | 28 | ||||
-rw-r--r-- | src/libdebug/debug.h | 1 |
2 files changed, 29 insertions, 0 deletions
diff --git a/src/libdebug/debug.c b/src/libdebug/debug.c index 44902ea..5becb02 100644 --- a/src/libdebug/debug.c +++ b/src/libdebug/debug.c @@ -24,7 +24,9 @@ #include <stdint.h> #include <errno.h> #include <math.h> +#include <time.h> #include <sys/ioctl.h> +#include <sys/time.h> #include "debug.h" const char *debug_level[] = { @@ -89,6 +91,7 @@ struct debug_cat { }; int debuglevel = DEBUG_INFO; +int debug_date = 0; uint64_t debug_mask = ~0; extern int num_kanal; @@ -148,6 +151,15 @@ void _printdebug(const char *file, const char __attribute__((unused)) *function, get_win_size(&w, &h); printf("\0337\033[%d;%dr\0338", debug_limit_scroll + 1, h); } + if (debug_date) { + struct timeval tv; + struct tm *tm; + + gettimeofday(&tv, NULL); + tm = localtime(&tv.tv_sec); + + printf("%04d-%02d-%02d %02d:%02d:%02d.%03d ", tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, (int)(tv.tv_usec / 10000.0)); + } printf("%s%s:%4d %s: %s\033[0;39m", debug_cat[cat].color, file, line, debug_level[level], buffer); if (debug_limit_scroll) printf("\0337\033[%d;%dr\0338", 1, h); @@ -190,6 +202,17 @@ const char *debug_db(double level_db) return text; } +void debug_print_help(void) +{ + printf(" -v --verbose <level> | <level>,<category>[,<category>[,...]] | list\n"); + printf(" Use 'list' to get a list of all levels and categories\n"); + printf(" Verbose level: digit of debug level (default = '%d')\n", debuglevel); + printf(" Verbose level+category: level digit followed by one or more categories\n"); + printf(" -> If no category is specified, all categories are selected\n"); + printf(" -v --verbose date\n"); + printf(" Show date with debug output\n"); +} + void debug_list_cat(void) { int i; @@ -210,6 +233,11 @@ int parse_debug_opt(const char *optarg) int i, max_level = 0; char *dup, *dstring, *p; + if (!strcasecmp(optarg, "date")) { + debug_date = 1; + return 0; + } + for (i = 0; debug_level[i]; i++) max_level = i; diff --git a/src/libdebug/debug.h b/src/libdebug/debug.h index 64cc155..bdcfd15 100644 --- a/src/libdebug/debug.h +++ b/src/libdebug/debug.h @@ -60,6 +60,7 @@ void _printdebug(const char *file, const char *function, int line, int cat, int const char *debug_amplitude(double level); const char *debug_db(double level_db); +void debug_print_help(void); void debug_list_cat(void); int parse_debug_opt(const char *opt); |