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, ... )
46 va_start( args, fmt );
47 fprintf(stdout, "DEBUG (%04lu@%-15.15s): ", line, function);
48 vfprintf( stdout, fmt, args );
50 fprintf(stdout, "\n");
52 if(output_log_syslog) {
53 va_start( args, fmt );
54 vsyslog(LOG_ERR, fmt, args );
59 void info_int( const char *file, const char *function, const unsigned long line, const char *fmt, ... )
66 va_start( args, fmt );
67 if(debug_flags) fprintf(stderr, "INFO (%04lu@%-15.15s): ", line, function);
68 else fprintf(stderr, "INFO: ");
69 vfprintf( stderr, fmt, args );
72 fprintf(stderr, "\n");
74 if(error_log_syslog) {
75 va_start( args, fmt );
76 vsyslog(LOG_INFO, fmt, args );
81 void error_int( const char *file, const char *function, const unsigned long line, const char *fmt, ... )
88 va_start( args, fmt );
89 if(debug_flags) fprintf(stderr, "ERROR (%04lu@%-15.15s): ", line, function);
90 else fprintf(stderr, "ERROR: ");
91 vfprintf( stderr, fmt, args );
95 fprintf(stderr, " (errno %d, %s)\n", errno, strerror(errno));
98 else fprintf(stderr, "\n");
100 if(error_log_syslog) {
101 va_start( args, fmt );
102 vsyslog(LOG_ERR, fmt, args );
107 void fatal_int( const char *file, const char *function, const unsigned long line, const char *fmt, ... )
114 va_start( args, fmt );
115 if(debug_flags) fprintf(stderr, "FATAL (%04lu@%-15.15s): ", line, function);
116 else fprintf(stderr, "FATAL: ");
117 vfprintf( stderr, fmt, args );
121 fprintf(stderr, "\n");
123 if(error_log_syslog) {
124 va_start( args, fmt );
125 vsyslog(LOG_CRIT, fmt, args );
132 void log_access( const char *fmt, ... )
139 va_start( args, fmt );
140 vfprintf( stdaccess, fmt, args );
142 fprintf( stdaccess, "\n");
146 if(access_log_syslog) {
147 va_start( args, fmt );
148 vsyslog(LOG_INFO, fmt, args );