22 #ifndef LOGGING_H_INCLUDE 23 #define LOGGING_H_INCLUDE 56 #define SCHE_PRONAME "scheduler" 74 #define FATAL(...) do { \ 75 lprintf(main_log, "FATAL %s.%d: ", __FILE__, __LINE__); \ 76 lprintf(main_log, __VA_ARGS__); \ 77 lprintf(main_log, "\n"); \ 78 lprintf(main_log, "FATAL errno is: %s\n", strerror(errno)); \ 82 #define THREAD_FATAL(file, ...) do { \ 83 con_printf(file, "THREAD_FATAL %s.%d: ", __FILE__, __LINE__); \ 84 con_printf(file, __VA_ARGS__); \ 85 con_printf(file, "\n"); \ 86 con_printf(file, "THREAD_FATAL errno is: %s\n", strerror(errno)); \ 87 g_thread_exit(NULL); } while(0) 90 #define ERROR(...) do { \ 91 lprintf(main_log, "ERROR %s.%d: ", __FILE__, __LINE__); \ 92 lprintf(main_log, __VA_ARGS__); \ 93 lprintf(main_log, "\n"); } while(0) 96 #define PQ_ERROR(pg_r, ...) { \ 97 lprintf(main_log, "ERROR %s.%d: ", __FILE__, __LINE__); \ 98 lprintf(main_log, __VA_ARGS__); \ 99 lprintf(main_log, "\n"); \ 100 lprintf(main_log, "ERROR postgresql error: %s\n", PQresultErrorMessage(pg_r)); } \ 104 #define TEST_NOTIFY verbose > 0 105 #define NOTIFY(...) if(TEST_NOTIFY) do { \ 106 lprintf(main_log, "NOTE: "); \ 107 lprintf(main_log, __VA_ARGS__); \ 108 lprintf(main_log, "\n"); } while(0) 111 #define TEST_WARNING verbose > 1 112 #define WARNING(...) if(TEST_WARNING) do { \ 113 lprintf(main_log, "WARNING %s.%d: ", __FILE__, __LINE__); \ 114 lprintf(main_log, __VA_ARGS__); \ 115 lprintf(main_log, "\n"); } while(0) 121 #define TVERB_JOB (verbose & 0x8) 122 #define TVERB_AGENT (verbose & 0x10) 123 #define TVERB_SCHED (verbose & 0x20) 124 #define TVERB_EVENT (verbose & 0x40) 125 #define TVERB_INTER (verbose & 0x80) 126 #define TVERB_DATAB (verbose & 0x100) 127 #define TVERB_HOST (verbose & 0x200) 128 #define TVERB_SPECIAL (verbose & 0x400) 129 #define V_JOB(...) if(TVERB_JOB) log_printf(__VA_ARGS__) 130 #define V_AGENT(...) if(TVERB_AGENT) log_printf(__VA_ARGS__) 131 #define V_SCHED(...) if(TVERB_SCHED) log_printf(__VA_ARGS__) 132 #define V_EVENT(...) if(TVERB_EVENT) log_printf(__VA_ARGS__) 133 #define V_INTERFACE(...) if(TVERB_INTER) con_printf(main_log, __VA_ARGS__) 134 #define V_DATABASE(...) if(TVERB_DATAB) log_printf(__VA_ARGS__) 135 #define V_HOST(...) if(TVERB_HOST) log_printf(__VA_ARGS__) 136 #define V_SPECIAL(...) if(TVERB_SPECIAL) log_printf(__VA_ARGS__) 142 log_t*
log_new(gchar* log_name, gchar* pro_name, pid_t pro_pid);
143 log_t*
log_new_FILE(FILE* log_file, gchar* log_name, gchar* pro_name, pid_t pro_pid);
150 #define log_printf(...) lprintf(main_log, __VA_ARGS__) 151 #define con_printf(log, ...) clprintf(log, __FILE__, __LINE__, __VA_ARGS__)
FILE * log_file
The log file itself.
gchar * pro_name
What should be printed as the process name.
int lprintf(log_t *log, const char *fmt,...)
Main logging function.
uint16_t s_line
Sample source line number.
int vlprintf(log_t *log, const char *fmt, va_list args)
The provides the same functionality for lprintf as vprintf does for printf.
int clprintf(log_t *log, char *s_name, uint16_t s_line, const char *fmt,...)
gchar * log_name
The name of the log file that will be printed to.
pid_t pro_pid
The pid of the process.
void log_destroy(log_t *log)
Free memory associated with the log file.
log_t * log_new_FILE(FILE *log_file, gchar *log_name, gchar *pro_name, pid_t pro_pid)
Creates a log file structure based on an already created FILE*.
log_t * log_new(gchar *log_name, gchar *pro_name, pid_t pro_pid)
Creates a new log.
char * s_name
Sample source file name.