diff --git a/os/glog/glog_logger.go b/os/glog/glog_logger.go index 8e5f11ed3..891bd2ab3 100644 --- a/os/glog/glog_logger.go +++ b/os/glog/glog_logger.go @@ -228,7 +228,9 @@ func (l *Logger) printToWriter(ctx context.Context, input *HandlerInput) { } // Allow output to stdout? if l.config.StdoutPrint { - input.Stdout() + if err := input.Stdout(); err != nil { + intlog.Error(ctx, err) + } } } else { if _, err := l.config.Writer.Write(input.Buffer().Bytes()); err != nil { diff --git a/os/glog/glog_logger_handler.go b/os/glog/glog_logger_handler.go index 53e090ca8..152629e90 100644 --- a/os/glog/glog_logger_handler.go +++ b/os/glog/glog_logger_handler.go @@ -10,6 +10,7 @@ import ( "bytes" "context" "github.com/fatih/color" + "github.com/gogf/gf/internal/intlog" "os" "time" ) @@ -59,12 +60,22 @@ func (i *HandlerInput) Buffer() *bytes.Buffer { } // Stdout print log to console -func (i *HandlerInput) Stdout() { - _, _ = os.Stdout.Write([]byte(i.TimeFormat)) +func (i *HandlerInput) Stdout() error { + if _, err := os.Stdout.Write([]byte(i.TimeFormat)); err != nil { + intlog.Error(i.Ctx, err) + return err + } fg := i.getLevelFormatColor() - _, _ = color.New(fg).Print(" " + i.LevelFormat + " ") + if _, err := color.New(fg).Print(" " + i.LevelFormat + " "); err != nil { + intlog.Error(i.Ctx, err) + return err + } msg := i.GetContent() - _, _ = os.Stdout.Write(msg.Bytes()) + if _, err := os.Stdout.Write(msg.Bytes()); err != nil { + intlog.Error(i.Ctx, err) + return err + } + return nil } // GetContent returns the primary content.