Created
          April 14, 2016 18:18 
        
      - 
      
 - 
        
Save julenka/ff3c58eda01c5e4257eb580f1aa70531 to your computer and use it in GitHub Desktop.  
    Windows win32 log.h
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #pragma once | |
| #ifndef LOG_LEVEL | |
| #define LOG_LEVEL 4 // 0 = nothing, 5 = verbose | |
| #endif | |
| #include <stdio.h> | |
| #define _NOP do{}while(0) | |
| #define _LOG(fmt, ...) wprintf_s(fmt, ##__VA_ARGS__) | |
| #if LOG_LEVEL >= 5 | |
| #define LOG_VERBOSE(fmt, ...) _LOG(fmt, ##__VA_ARGS__) | |
| #else | |
| #define LOG_VERBOSE(fmt, ...) _NOP | |
| #endif | |
| #if LOG_LEVEL >= 4 | |
| #define LOG_DEBUG(fmt, ...) _LOG(fmt, ##__VA_ARGS__) | |
| #else | |
| #define LOG_DEBUG(fmt, ...) _NOP | |
| #endif | |
| #if LOG_LEVEL >= 3 | |
| #define LOG_INFO(fmt, ...) _LOG(fmt, ##__VA_ARGS__) | |
| #else | |
| #define LOG_INFO(fmt, ...) _NOP | |
| #endif | |
| #if LOG_LEVEL >= 2 | |
| #define LOG_WARN(fmt, ...) _LOG(fmt, ##__VA_ARGS__) | |
| #else | |
| #define LOG_WARN(fmt, ...) _NOP | |
| #endif | |
| #if LOG_LEVEL >= 1 | |
| #define LOG_ERROR(fmt, ...) _LOG(fmt, ##__VA_ARGS__) | |
| #else | |
| #define LOG_ERROR(fmt, ...) _NOP | |
| #endif | |
| #define FATAL(fmt, ...) do { _LOG("FATAL: " fmt, ##__VA_ARGS__); abort(); } while(0) | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment