]> arthur.barton.de Git - netdata.git/commitdiff
enable line buffering on all log files
authorCosta Tsaousis <costa@tsaousis.gr>
Sun, 8 May 2016 00:45:51 +0000 (03:45 +0300)
committerCosta Tsaousis <costa@tsaousis.gr>
Sun, 8 May 2016 00:45:51 +0000 (03:45 +0300)
src/daemon.c
src/log.c

index 6b671bee1fa7a6f4b1ea7bed26576202e1ebe0b9..33af252da004838eec204664cf5ed1937fb8b1af 100644 (file)
@@ -208,6 +208,8 @@ int become_daemon(int dont_fork, int close_all_files, const char *user, const ch
                                *access_fd = -1;
                                return -1;
                        }
+                       if(setvbuf(*access_fp, NULL, _IOLBF, 0) != 0)
+                               error("Cannot set line buffering on access.log");
                }
        }
 
@@ -301,6 +303,10 @@ int become_daemon(int dont_fork, int close_all_files, const char *user, const ch
                        dup2(output_fd, STDOUT_FILENO);
                        close(output_fd);
                }
+
+               if(setvbuf(stdout, NULL, _IOLBF, 0) != 0)
+                       error("Cannot set line buffering on debug.log");
+
                output_fd = -1;
        }
        else dup2(dev_null, STDOUT_FILENO);
@@ -310,6 +316,10 @@ int become_daemon(int dont_fork, int close_all_files, const char *user, const ch
                        dup2(error_fd, STDERR_FILENO);
                        close(error_fd);
                }
+
+               if(setvbuf(stderr, NULL, _IOLBF, 0) != 0)
+                       error("Cannot set line buffering on error.log");
+
                error_fd = -1;
        }
        else dup2(dev_null, STDERR_FILENO);
index 2db0c662e3bad87442147222da47d081ff4e55e3..717126a69e14f74854c5d029250f0735c33ec7ef 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -131,7 +131,7 @@ void debug_int( const char *file, const char *function, const unsigned long line
        vfprintf( stdout, fmt, args );
        va_end( args );
        fprintf(stdout, "\n");
-       fflush( stdout );
+       // fflush( stdout );
 
        if(output_log_syslog) {
                va_start( args, fmt );
@@ -229,7 +229,7 @@ void log_access( const char *fmt, ... )
                vfprintf( stdaccess, fmt, args );
                va_end( args );
                fprintf( stdaccess, "\n");
-               fflush( stdaccess );
+               // fflush( stdaccess );
        }
 
        if(access_log_syslog) {