gimp but for windows: a wayland compositor
git clone https://github.com/m-col/wimp
Files | Refs | Readme

-rw-r--r-- src/log.c


      1 #include <stdio.h>
      2 #include <time.h>
      3 #include <wlr/util/log.h>
      4 
      5 
      6 static enum wlr_log_importance log_importance;
      7 
      8 
      9 static const char *verbosity_headers[] = {
     10     [WLR_SILENT] = "",
     11     [WLR_ERROR] = "[ERROR]",
     12     [WLR_INFO] = "[INFO]",
     13     [WLR_DEBUG] = "[DEBUG]",
     14 };
     15 
     16 
     17 static void log_stdout(enum wlr_log_importance verbosity, const char *fmt, va_list args) {
     18     if (verbosity > log_importance) {
     19 	return;
     20     }
     21 
     22     time_t t = time(NULL);
     23     struct tm *now = localtime(&t);
     24     char nows[20];
     25     strftime(nows, 20, "%F %T", now);
     26 
     27     fprintf(stdout, "%s %s: ", nows, verbosity_headers[verbosity]);
     28     vfprintf(stdout, fmt, args);
     29     fprintf(stdout, "\n");
     30 }
     31 
     32 
     33 void init_log(enum wlr_log_importance log_level) {
     34     log_importance = log_level;
     35     wlr_log_init(log_importance, log_stdout);
     36 }
     37