githubnemo / CompileDaemon

Very simple compile daemon for Go
BSD 2-Clause "Simplified" License
1.63k stars 156 forks source link

Flush logging buffer before printing CompileDaemon output #16

Open evanpurkhiser opened 8 years ago

evanpurkhiser commented 8 years ago

Since the logger buffer isn't flushed until another newline is found it's possible that the output that CompileDaemon generates can be affected by ANSII escape sequences that haven't been terminated due to no newline being printed.

For example, a program that writes output with color, writes a newline, then immediately writes the color reset escape sequence. Because the output is buffered the reset escape sequence won't be written until a newline is outputted. However, if the program is terminated and restarted it will never write the reset escape sequence and the output from CompileDaemon (eg "Running build command!") will be affected by the previous escape sequence.

Obviously this could be fixed by outputting the reset sequence before writing a newline, but it seems like the 'correct' solution would be for this software to flush the buffer when a program is recompiled.

githubnemo commented 8 years ago
package main
import "fmt"

func main() {
    fmt.Println(string(27) + "[31mColored.");
    fmt.Print(string(27) + "[0m");
}

Is this your test case?

evanpurkhiser commented 8 years ago

Correct.

image