Horje
log like printf c++ Code Example
log like printf c++
void _proxy_log(log_level_t level, const char *fmt, ...)
    __attribute__((format (printf, 2, 3)));

#define proxy_log(level, fmt, ...) _proxy_log(level, fmt"\n", ##__VA_ARGS__)

void _proxy_log(log_level_t level, const char *fmt, ...) {
    va_list arg;
    FILE *log_file = (level == LOG_ERROR) ? err_log : info_log;

    /* Check if the message should be logged */
    if (level > log_level)
        return;

    /* Write the error message */
    va_start(arg, fmt);
    vfprintf(log_file, fmt, arg);
    va_end(arg);

#ifdef DEBUG
    fflush(log_file);
    fsync(fileno(log_file));
#endif
}




Cpp

Related
how to show constellations in starry night orion special edition Code Example how to show constellations in starry night orion special edition Code Example
how to change the value of a key in hashmp in c++ Code Example how to change the value of a key in hashmp in c++ Code Example
template c++ Code Example template c++ Code Example
round c++ Code Example round c++ Code Example
c++ cin accept only numbers Code Example c++ cin accept only numbers Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
11