Search
 
SCRIPT & CODE EXAMPLE
 

CPP

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"
", ##__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
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: Redragon m609 weight 
Cpp :: infix to prefix using cpp linked list program 
Cpp :: constant qualifier c++ "error display" 
Cpp :: convert c++ program to c online 
Cpp :: Swift if...else Statement 
Cpp :: how to use comparitor in priority queu in c++ 
Cpp :: c++ negate boolean 
Cpp :: tic tac toe in cpp 
Cpp :: Consider a pair of integers, (a,b). The following operations can be performed on (a,b) in any order, zero or more times: - (a,b) - ( a+b, b ) - (a,b) - ( a, a+b ) 
Cpp :: how to check code execution time in visual studio c++ 
Cpp :: c++ const shared_ptr 
Cpp :: Chef and Feedback codechef solution in cpp 
Cpp :: how to analyse a poem 
Cpp :: c++ get last element in array 
Cpp :: c++ if else if 
Cpp :: how to append two vectors in c++ 
Cpp :: declare a variable in cpp 
Cpp :: C++ Assignment Operators 
Cpp :: function overloading in cpp 
Cpp :: 2927260.eps 2927262.jpg 2927263.ai License free.txt License premium.txt 
C :: bold text in c 
C :: boolean in c 
C :: c random list 
C :: how to print hello world in c 
C :: random number c 
C :: #![feature]` may not be used on the // stable release channel 
C :: dart in android studio 
C :: matplotlib plot circle marker 
C :: connect servo to arduino 
C :: goto statement in c 
ADD CONTENT
Topic
Content
Source link
Name
4+1 =