32 #include <sys/types.h>
41 #ifdef BACKTRACE_SUPPORT
59 va_start ( args, fmt );
60 rc = vfprintf ( stderr, fmt, args );
69 va_start ( args, fmt );
70 rc = vfprintf ( stdout, fmt, args );
77 return vfprintf ( stderr, fmt, args );
82 return vfprintf ( stdout, fmt, args );
89 fprintf ( stderr,
"\n" );
96 fprintf ( stdout,
"\n" );
116 fprintf ( stderr,
"Security problem while vsyslog_buf(): "
117 "_syslog_buffer_filled == %lu; "
150 va_start ( args, fmt );
184 void _critical (
const char *
const function_name,
const char *fmt, ... )
189 struct timespec abs_time;
190 clock_gettime ( CLOCK_REALTIME, &abs_time );
191 abs_time.tv_sec += 1;
199 pthread_t thread = pthread_self();
200 pid_t pid = getpid();
201 outfunct[method] (
"Critical (pid: %u; thread: %p): %s(): ", pid, thread, function_name );
202 va_start ( args, fmt );
205 outfunct[method] (
" (current errno %i: %s)", errno, strerror ( errno ) );
208 #ifdef BACKTRACE_SUPPORT
213 strings = backtrace_symbols ( buf, backtrace_len );
215 if ( strings == NULL ) {
216 outfunct[method] (
"_critical(): Got error, but cannot print the backtrace. Current errno: %u: %s\n",
217 errno, strerror ( errno ) );
220 exit ( EXIT_FAILURE );
223 for (
int j = 1; j < backtrace_len; j++ ) {
224 outfunct[method] (
" %s", strings[j] );
238 void _error (
const char *
const function_name,
const char *fmt, ... )
251 pthread_t thread = pthread_self();
252 pid_t pid = getpid();
254 outfunct[method] ( *
debug ?
"Error (pid: %u; thread: %p): %s(): " :
"Error: ", pid, thread, function_name );
255 va_start ( args, fmt );
260 outfunct[method] (
" (%i: %s)", errno, strerror ( errno ) );
270 void _info (
const char *
const function_name,
const char *fmt, ... )
283 pthread_t thread = pthread_self();
284 pid_t pid = getpid();
286 outfunct[method] ( *
debug ?
"Info (pid: %u; thread: %p): %s(): " :
"Info: ", pid, thread, function_name );
287 va_start ( args, fmt );
298 void _warning (
const char *
const function_name,
const char *fmt, ... )
311 pthread_t thread = pthread_self();
312 pid_t pid = getpid();
314 outfunct[method] ( *
debug ?
"Warning (pid: %u; thread: %p): %s(): " :
"Warning: ", pid, thread, function_name );
315 va_start ( args, fmt );
326 #ifdef _DEBUG_SUPPORT
327 void _debug (
int debug_level,
const char *
const function_name,
const char *fmt, ... )
334 if ( debug_level > *
debug )
340 pthread_t thread = pthread_self();
341 pid_t pid = getpid();
343 outfunct[method] (
"Debug%u (pid: %u; thread: %p): %s(): ", debug_level, pid, thread, function_name );
344 va_start ( args, fmt );
356 void error_init (
void *_outputmethod,
int *_quiet,
int *_verbose,
int *_debug )
369 static pthread_mutex_t error_mutex = PTHREAD_MUTEX_INITIALIZER;