gte/cmd/android-app/component/logger.go

28 lines
393 B
Go
Raw Normal View History

2022-10-18 16:58:12 +02:00
package component
2022-10-20 13:58:48 +02:00
import (
"fmt"
"time"
)
2022-10-18 16:58:12 +02:00
type Logger struct {
lines []string
}
func NewLogger() *Logger {
return &Logger{
lines: []string{},
}
}
func (l *Logger) Log(line string) {
2022-10-23 12:45:21 +02:00
l.lines = append(l.lines, fmt.Sprintf("%s: %s", time.Now().Format(time.StampMicro), line))
2022-10-20 14:49:33 +02:00
if len(l.lines) > 50 {
l.lines = l.lines[1:]
}
2022-10-18 16:58:12 +02:00
}
func (l *Logger) Lines() []string {
2022-10-20 14:49:33 +02:00
return l.lines
2022-10-18 16:58:12 +02:00
}