Ensure logs are flushed

This ensures that anything written to the logs are synced as they
happen.

This also changes the error message of the libcontainer error.  The
original idea was to have this extra information in the message but it
makes it hard to parse and if the caller needed this information they
can just get it from the error type.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
Michael Crosby 2016-03-11 17:08:03 -08:00
parent 5a91c338f5
commit 8f206929b2
2 changed files with 2 additions and 3 deletions

View File

@ -1,7 +1,6 @@
package libcontainer
import (
"fmt"
"io"
"text/template"
"time"
@ -76,7 +75,7 @@ type genericError struct {
}
func (e *genericError) Error() string {
return fmt.Sprintf("[%d] %s: %s", e.ECode, e.ECode, e.Message)
return e.Message
}
func (e *genericError) Code() ErrorCode {

View File

@ -100,7 +100,7 @@ func main() {
logrus.SetLevel(logrus.DebugLevel)
}
if path := context.GlobalString("log"); path != "" {
f, err := os.OpenFile(path, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666)
f, err := os.OpenFile(path, os.O_CREATE|os.O_WRONLY|os.O_APPEND|os.O_SYNC, 0666)
if err != nil {
return err
}