mirror of
https://codeberg.org/scip/yadu.git
synced 2025-12-17 04:30:59 +01:00
fix #6: support LogValuer() attributes
This commit is contained in:
@@ -16,6 +16,12 @@ type Ammo struct {
|
||||
Range int
|
||||
}
|
||||
|
||||
func (a *Ammo) LogValue() slog.Value {
|
||||
return slog.GroupValue(
|
||||
slog.String("Forweapon", a.Forweapon),
|
||||
)
|
||||
}
|
||||
|
||||
type Enemy struct {
|
||||
Alive bool
|
||||
Health int
|
||||
@@ -24,6 +30,12 @@ type Enemy struct {
|
||||
Ammo []Ammo
|
||||
}
|
||||
|
||||
func (e *Enemy) LogValue() slog.Value {
|
||||
return slog.GroupValue(
|
||||
slog.String("name", e.Name),
|
||||
)
|
||||
}
|
||||
|
||||
func removeTime(_ []string, a slog.Attr) slog.Attr {
|
||||
if a.Key == slog.TimeKey {
|
||||
return slog.Attr{}
|
||||
@@ -47,6 +59,7 @@ func main() {
|
||||
}
|
||||
|
||||
slog.Info("info", "enemy", e, "spawn", 199)
|
||||
slog.Info("info", "ammo", &Ammo{Forweapon: "axe", Impact: 1})
|
||||
slog.Info("connecting", "enemies", 100, "players", 2, "world", "600x800")
|
||||
slog.Debug("debug text")
|
||||
slog.Error("error")
|
||||
|
||||
Reference in New Issue
Block a user