feat (user): add logger on crud

This commit is contained in:
dpurbosakti
2025-08-20 09:36:13 +07:00
parent d476a31422
commit b20380b1f6
3 changed files with 251 additions and 45 deletions
+13 -2
View File
@@ -27,13 +27,24 @@ type ErrorInfo struct {
Raw error
}
func SetLogInfo(e Event, data any) {
// SetLogInfo updates the event and logs it.
// The first argument is the event, the second is the data.
// Variadic arguments:
// - first (optional): status
// - second (optional): action
func SetLogInfo(e *Event, data any, args ...string) {
dataString, _ := json.Marshal(data)
if len(args) > 0 {
e.Status = args[0]
}
if len(args) > 1 {
e.Action = args[1]
}
lz.O.Info().
String("source", e.Source).
String("feature", e.Feature).
String("action", e.Action).
String("status", "started").
String("status", e.Status).
String("input", string(dataString)).
Send()
}