mirror of
https://github.com/sipeed/NanoKVM.git
synced 2026-09-11 09:26:44 -05:00
perf: merge H.264 SPS and PPS into I-frame perf: refactor MJPEG frame detection perf: update log timestamp to millisecond precision perf: update script `update-nanokvm.py` chore: bump Go to 1.23 chore: bump golang.org/x/net to v0.37.0
43 lines
723 B
Go
43 lines
723 B
Go
package logger
|
|
|
|
import (
|
|
"bytes"
|
|
"fmt"
|
|
"path/filepath"
|
|
|
|
"github.com/sirupsen/logrus"
|
|
)
|
|
|
|
type formatter struct{}
|
|
|
|
func (f *formatter) Format(entry *logrus.Entry) ([]byte, error) {
|
|
var (
|
|
text string
|
|
buffer *bytes.Buffer
|
|
)
|
|
|
|
if entry.Buffer != nil {
|
|
buffer = entry.Buffer
|
|
} else {
|
|
buffer = &bytes.Buffer{}
|
|
}
|
|
|
|
now := entry.Time.Format("2006-01-02 15:04:05.000")
|
|
|
|
if entry.HasCaller() {
|
|
fileName := filepath.Base(entry.Caller.File)
|
|
text = fmt.Sprintf(
|
|
"[%s] [%s] [%s:%d] %s\n",
|
|
now, entry.Level, fileName, entry.Caller.Line, entry.Message,
|
|
)
|
|
} else {
|
|
text = fmt.Sprintf(
|
|
"[%s] [%s] %s \n",
|
|
now, entry.Level, entry.Message,
|
|
)
|
|
}
|
|
|
|
buffer.WriteString(text)
|
|
return buffer.Bytes(), nil
|
|
}
|