]> arthur.barton.de Git - netdata.git/blobdiff - src/log.c
Merge pull request #17 from alonbl/build
[netdata.git] / src / log.c
index 0ba8a228de423335893489269b0586873ad20423..21c44afc866870e8fff989b6d879a6a011727ded 100755 (executable)
--- a/src/log.c
+++ b/src/log.c
@@ -1,3 +1,6 @@
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 #include <time.h>
 #include <syslog.h>
 #include <errno.h>
@@ -6,10 +9,13 @@
 #include <stdlib.h>
 
 #include "log.h"
+#include "common.h"
+
 
 // ----------------------------------------------------------------------------
 // LOG
 
+const char *program_name = "";
 unsigned long long debug_flags = DEBUG;
 
 int silent = 0;
@@ -39,12 +45,11 @@ void log_date(FILE *out)
 
 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");
@@ -58,14 +63,13 @@ void debug_int( const char *file, const char *function, const unsigned long line
 
 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 );
 
@@ -80,14 +84,13 @@ void info_int( const char *file, const char *function, const unsigned long line,
 
 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 );
 
@@ -106,14 +109,13 @@ void error_int( const char *file, const char *function, const unsigned long line
 
 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 );