10 // ----------------------------------------------------------------------------
13 unsigned long long debug_flags = DEBUG;
18 FILE *stdaccess = NULL;
20 int access_log_syslog = 1;
21 int error_log_syslog = 1;
22 int output_log_syslog = 1; // debug log
25 void log_date(FILE *out)
34 if (tmp == NULL) return;
35 if (strftime(outstr, sizeof(outstr), "%y-%m-%d %H:%M:%S", tmp) == 0) return;
37 fprintf(out, "%s: ", outstr);
40 void debug_int( const char *file, const char *function, const unsigned long line, const char *fmt, ... )
45 va_start( args, fmt );
46 fprintf(stdout, "DEBUG (%04lu@%-10.10s:%-15.15s): ", line, file, function);
47 vfprintf( stdout, fmt, args );
49 fprintf(stdout, "\n");
51 if(output_log_syslog) {
52 va_start( args, fmt );
53 vsyslog(LOG_ERR, fmt, args );
58 void info_int( const char *file, const char *function, const unsigned long line, const char *fmt, ... )
64 va_start( args, fmt );
65 if(debug_flags) fprintf(stderr, "INFO (%04lu@%-10.10s:%-15.15s): ", line, file, function);
66 else fprintf(stderr, "INFO: ");
67 vfprintf( stderr, fmt, args );
70 fprintf(stderr, "\n");
72 if(error_log_syslog) {
73 va_start( args, fmt );
74 vsyslog(LOG_INFO, fmt, args );
79 void error_int( const char *file, const char *function, const unsigned long line, const char *fmt, ... )
85 va_start( args, fmt );
86 if(debug_flags) fprintf(stderr, "ERROR (%04lu@%-10.10s:%-15.15s): ", line, file, function);
87 else fprintf(stderr, "ERROR: ");
88 vfprintf( stderr, fmt, args );
92 fprintf(stderr, " (errno %d, %s)\n", errno, strerror(errno));
95 else fprintf(stderr, "\n");
97 if(error_log_syslog) {
98 va_start( args, fmt );
99 vsyslog(LOG_ERR, fmt, args );
104 void fatal_int( const char *file, const char *function, const unsigned long line, const char *fmt, ... )
110 va_start( args, fmt );
111 if(debug_flags) fprintf(stderr, "FATAL (%04lu@%-10.10s:%-15.15s): ", line, file, function);
112 else fprintf(stderr, "FATAL: ");
113 vfprintf( stderr, fmt, args );
117 fprintf(stderr, "\n");
119 if(error_log_syslog) {
120 va_start( args, fmt );
121 vsyslog(LOG_CRIT, fmt, args );
128 void log_access( const char *fmt, ... )
135 va_start( args, fmt );
136 vfprintf( stdaccess, fmt, args );
138 fprintf( stdaccess, "\n");
142 if(access_log_syslog) {
143 va_start( args, fmt );
144 vsyslog(LOG_INFO, fmt, args );