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 );
184void _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] );
238void _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 ) );
270void _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 );
298void _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 );
327void _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 );
356void error_init (
void *_outputmethod,
int *_quiet,
int *_verbose,
int *_debug )
369 static pthread_mutex_t error_mutex = PTHREAD_MUTEX_INITIALIZER;
#define OUTPUT_LOCK_TIMEOUT
static int syslog_buf(const char *fmt,...)
static void flush_stdout(int level)
static int vprintf_stdout(const char *fmt, va_list args)
void(* flushfunct_t)(int level)
void _warning(const char *const function_name, const char *fmt,...)
void error_init(void *_outputmethod, int *_quiet, int *_verbose, int *_debug)
int(* voutfunct_t)(const char *format, va_list ap)
void error_init_ipc(ipc_type_t _ipc_type)
static int vsyslog_buf(const char *fmt, va_list args)
int(* outfunct_t)(const char *format,...)
void _info(const char *const function_name, const char *fmt,...)
static int printf_stdout(const char *fmt,...)
static voutfunct_t voutfunct[]
static int printf_stderr(const char *fmt,...)
static int * outputmethod
void _critical(const char *const function_name, const char *fmt,...)
static flushfunct_t flushfunct[]
static int vprintf_stderr(const char *fmt, va_list args)
pthread_mutex_t * error_mutex_p
size_t _syslog_buffer_filled
static void syslog_flush(int level)
static void flush_stderr(int level)
void _error(const char *const function_name, const char *fmt,...)
static char _syslog_buffer[(1<< 16)+1]
static outfunct_t outfunct[]
enum outputmethod outputmethod_t
int pthread_mutex_init_shared(pthread_mutex_t **mutex_p)
int pthread_mutex_reltimedlock(pthread_mutex_t *mutex_p, long tv_sec, long tv_nsec)
int pthread_mutex_destroy_shared(pthread_mutex_t *mutex_p)