feat (user): add logger on crud
This commit is contained in:
+13
-2
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user