+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
#include <time.h>
#include <syslog.h>
#include <errno.h>
#include <stdlib.h>
#include "log.h"
+#include "common.h"
+
// ----------------------------------------------------------------------------
// LOG
+const char *program_name = "";
unsigned long long debug_flags = DEBUG;
int silent = 0;
void debug_int( const char *file, const char *function, const unsigned long line, const char *fmt, ... )
{
- if(file) { ; }
va_list args;
log_date(stdout);
va_start( args, fmt );
- fprintf(stdout, "DEBUG (%04lu@%-15.15s): ", line, function);
+ fprintf(stdout, "DEBUG (%04lu@%-10.10s:%-15.15s): %s: ", line, file, function, program_name);
vfprintf( stdout, fmt, args );
va_end( args );
fprintf(stdout, "\n");
void info_int( const char *file, const char *function, const unsigned long line, const char *fmt, ... )
{
- if(file) { ; }
va_list args;
log_date(stderr);
va_start( args, fmt );
- if(debug_flags) fprintf(stderr, "INFO (%04lu@%-15.15s): ", line, function);
- else fprintf(stderr, "INFO: ");
+ if(debug_flags) fprintf(stderr, "INFO (%04lu@%-10.10s:%-15.15s): %s: ", line, file, function, program_name);
+ else fprintf(stderr, "INFO: %s: ", program_name);
vfprintf( stderr, fmt, args );
va_end( args );
void error_int( const char *file, const char *function, const unsigned long line, const char *fmt, ... )
{
- if(file) { ; }
va_list args;
log_date(stderr);
va_start( args, fmt );
- if(debug_flags) fprintf(stderr, "ERROR (%04lu@%-15.15s): ", line, function);
- else fprintf(stderr, "ERROR: ");
+ if(debug_flags) fprintf(stderr, "ERROR (%04lu@%-10.10s:%-15.15s): %s: ", line, file, function, program_name);
+ else fprintf(stderr, "ERROR: %s: ", program_name);
vfprintf( stderr, fmt, args );
va_end( args );
void fatal_int( const char *file, const char *function, const unsigned long line, const char *fmt, ... )
{
- if(file) { ; }
va_list args;
log_date(stderr);
va_start( args, fmt );
- if(debug_flags) fprintf(stderr, "FATAL (%04lu@%-15.15s): ", line, function);
- else fprintf(stderr, "FATAL: ");
+ if(debug_flags) fprintf(stderr, "FATAL (%04lu@%-10.10s:%-15.15s): %s: ", line, file, function, program_name);
+ else fprintf(stderr, "FATAL: %s: ", program_name);
vfprintf( stderr, fmt, args );
va_end( args );