duckstation

duckstation, but archived from the revision just before upstream changed it to a proprietary software project, this version is the libre one
git clone https://git.neptards.moe/u3shit/duckstation.git
Log | Files | Refs | README | LICENSE

cubeb_log.h (2112B)


      1 /*
      2  * Copyright © 2016 Mozilla Foundation
      3  *
      4  * This program is made available under an ISC-style license.  See the
      5  * accompanying file LICENSE for details.
      6  */
      7 
      8 #ifndef CUBEB_LOG
      9 #define CUBEB_LOG
     10 
     11 #include "cubeb/cubeb.h"
     12 
     13 #ifdef __cplusplus
     14 extern "C" {
     15 #endif
     16 
     17 #if defined(__GNUC__) || defined(__clang__)
     18 #define PRINTF_FORMAT(fmt, args) __attribute__((format(printf, fmt, args)))
     19 #if defined(__FILE_NAME__)
     20 #define __FILENAME__ __FILE_NAME__
     21 #else
     22 #define __FILENAME__                                                           \
     23   (__builtin_strrchr(__FILE__, '/') ? __builtin_strrchr(__FILE__, '/') + 1     \
     24                                     : __FILE__)
     25 #endif
     26 #else
     27 #define PRINTF_FORMAT(fmt, args)
     28 #include <string.h>
     29 #define __FILENAME__                                                           \
     30   (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
     31 #endif
     32 
     33 void
     34 cubeb_log_set(cubeb_log_level log_level, cubeb_log_callback log_callback);
     35 cubeb_log_level
     36 cubeb_log_get_level(void);
     37 cubeb_log_callback
     38 cubeb_log_get_callback(void);
     39 void
     40 cubeb_log_internal_no_format(const char * msg);
     41 void
     42 cubeb_log_internal(const char * filename, uint32_t line, const char * fmt, ...);
     43 
     44 #ifdef __cplusplus
     45 }
     46 #endif
     47 
     48 #define LOGV(msg, ...) LOG_INTERNAL(CUBEB_LOG_VERBOSE, msg, ##__VA_ARGS__)
     49 #define LOG(msg, ...) LOG_INTERNAL(CUBEB_LOG_NORMAL, msg, ##__VA_ARGS__)
     50 
     51 #define LOG_INTERNAL(level, fmt, ...)                                          \
     52   do {                                                                         \
     53     if (cubeb_log_get_level() >= level && cubeb_log_get_callback()) {          \
     54       cubeb_log_internal(__FILENAME__, __LINE__, fmt, ##__VA_ARGS__);          \
     55     }                                                                          \
     56   } while (0)
     57 
     58 /* Asynchronous logging macros to log in real-time callbacks. */
     59 /* Should not be used on android due to the use of global/static variables. */
     60 #define ALOGV(msg, ...) LOG_INTERNAL(CUBEB_LOG_VERBOSE, msg, ##__VA_ARGS__)
     61 #define ALOG(msg, ...) LOG_INTERNAL(CUBEB_LOG_NORMAL, msg, ##__VA_ARGS__)
     62 
     63 #endif // CUBEB_LOG