git.y1.nz

gbdk-2020

GameBoy Development Kit
download: https://git.y1.nz/archives/gbdk.tar.gz
README | Files | Log | Refs | LICENSE

gbdk-support/romusage/src/logging.c

      1 // logging.c
      2 
      3 #include <stdarg.h>
      4 #include <stdio.h>
      5 #include <stdbool.h>
      6 #include <stdint.h>
      7 
      8 #include "common.h"
      9 #include "logging.h"
     10 
     11 int output_level = OUTPUT_LEVEL_DEFAULT;
     12 
     13 
     14 #define VA_LIST_PRINT() \
     15     va_list args; \
     16     va_start (args, format); \
     17     if (get_option_is_web_mode()) { vfprintf (stdout, format, args); } else { vfprintf (stderr, format, args);} \
     18     va_end (args);
     19 
     20 
     21 void log_set_level(int new_output_level) {
     22     output_level = new_output_level;
     23 }
     24 
     25 void log_debug(const char * format, ...){
     26 
     27     if (output_level > OUTPUT_LEVEL_DEBUG) return;
     28     VA_LIST_PRINT();
     29 }
     30 
     31 void log_verbose(const char * format, ...){
     32 
     33     if (output_level > OUTPUT_LEVEL_VERBOSE) return;
     34     VA_LIST_PRINT();
     35 }
     36 
     37 void log_standard(const char * format, ...){
     38 
     39     // Only print if quiet mode and error_only are NOT enabled
     40     if ((output_level == OUTPUT_LEVEL_QUIET) ||
     41         (output_level == OUTPUT_LEVEL_ONLY_ERRORS)) return;
     42     VA_LIST_PRINT();
     43 }
     44 
     45 void log_warning(const char * format, ...){
     46 
     47     // Only print if quiet mode and error_only are NOT enabled
     48     if ((output_level == OUTPUT_LEVEL_QUIET) ||
     49         (output_level == OUTPUT_LEVEL_ONLY_ERRORS)) return;
     50     VA_LIST_PRINT();
     51 }
     52 
     53 void log_error(const char * format, ...){
     54 
     55     // Only print if quiet mode is NOT enabled
     56     if (output_level == OUTPUT_LEVEL_QUIET) return;
     57     VA_LIST_PRINT();
     58 }

This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.