transform log in writer

nats
Paulo Simão 2021-10-14 06:24:39 -03:00
parent a6a48c459b
commit 9602c569ec
1 changed files with 5 additions and 0 deletions

View File

@ -212,6 +212,11 @@ type Log struct {
History string `json:"history,omitempty"` History string `json:"history,omitempty"`
} }
func (l *Log) Write(p []byte) (n int, err error) {
l.AddHistory(string(p))
return len(p), nil
}
func (l *Log) AddHistory(s string) { func (l *Log) AddHistory(s string) {
s = fmt.Sprintf("* %s: %s", time.Now().Format("02/01/06 - 15:04:05"), s) s = fmt.Sprintf("* %s: %s", time.Now().Format("02/01/06 - 15:04:05"), s)
if l.History == "" { if l.History == "" {