project_files/frontlib/util/logging.h
changeset 7275 15f722e0b96f
parent 7224 5143861c83bd
child 7314 6171f0bad318
equal deleted inserted replaced
7273:8eed495fd8da 7275:15f722e0b96f
    15 /**
    15 /**
    16  * Returns a pointer to a static buffer, don't free or store.
    16  * Returns a pointer to a static buffer, don't free or store.
    17  */
    17  */
    18 char* flib_format_ip(uint32_t numip);
    18 char* flib_format_ip(uint32_t numip);
    19 
    19 
    20 void flib_log_e(const char *fmt, ...);
    20 /**
    21 void flib_log_w(const char *fmt, ...);
    21  * Evaluates the expression cond. If it is true, a formatted error will be logged.
    22 void flib_log_i(const char *fmt, ...);
    22  * Returns true if an error is logged, false otherwise (i.e. the boolean value of the argument)
    23 void flib_log_d(const char *fmt, ...);
    23  */
       
    24 #define log_e_if(cond, ...) _flib_fassert(__func__, FLIB_LOGLEVEL_ERROR, !(bool)(cond), __VA_ARGS__)
       
    25 #define log_w_if(cond, ...) _flib_fassert(__func__, FLIB_LOGLEVEL_WARNING, !(bool)(cond), __VA_ARGS__)
       
    26 
       
    27 /**
       
    28  * Shorthand for some common error types
       
    29  */
       
    30 #define log_badparams_if(cond) log_e_if(cond, "Invalid Parameters")
       
    31 #define log_oom_if(cond) log_e_if(cond, "Out of Memory")
       
    32 
       
    33 #define flib_log_e(...) _flib_flog(__func__, FLIB_LOGLEVEL_ERROR, __VA_ARGS__)
       
    34 #define flib_log_w(...) _flib_flog(__func__, FLIB_LOGLEVEL_WARNING, __VA_ARGS__)
       
    35 #define flib_log_i(...) _flib_flog(__func__, FLIB_LOGLEVEL_INFO, __VA_ARGS__)
       
    36 #define flib_log_d(...) _flib_flog(__func__, FLIB_LOGLEVEL_DEBUG, __VA_ARGS__)
       
    37 
       
    38 bool _flib_assert_params(const char *func, bool cond);
       
    39 bool _flib_fassert(const char *func, int level, bool cond, const char *fmt, ...);
       
    40 void _flib_flog(const char *func, int level, const char *fmt, ...);
    24 
    41 
    25 int flib_log_getLevel();
    42 int flib_log_getLevel();
    26 void flib_log_setLevel(int level);
    43 void flib_log_setLevel(int level);
    27 void flib_log_setFile(FILE *logfile);
    44 void flib_log_setFile(FILE *logfile);
    28 bool flib_log_isActive(int level);
    45 bool flib_log_isActive(int level);