diff --git a/logging.go b/logging.go index f0ab491..547a361 100644 --- a/logging.go +++ b/logging.go @@ -6,6 +6,7 @@ import ( "log/slog" "os" "regexp" + "strings" ) func New(c Customization) { @@ -88,7 +89,7 @@ func SetNumericLevel(level int) { func setDefaults(c *Customization) error { // \/ \/ \/ REQUIRED FIELDS \/ \/ \/ // - + // format, can be one of "json" or "text" switch { case len(c.Format) == 0: @@ -124,14 +125,12 @@ func setDefaults(c *Customization) error { return errors.New("Invalid application id, must be a valid uuid string.") } - - // /\ /\ /\ REQUIRED FIELDS /\ /\ /\ // return nil } -func Fatal(msg string, attrs ...interface{}) { +func Fatal(operation, correlationID, msg string, attrs ...interface{}) { L.Log.Log( L.Ctx, LevelFatal, @@ -140,7 +139,7 @@ func Fatal(msg string, attrs ...interface{}) { ) } -func Error(msg string, attrs ...interface{}) { +func Error(operation, correlationID, msg string, attrs ...interface{}) { L.Log.Log( L.Ctx, slog.LevelError, @@ -149,7 +148,7 @@ func Error(msg string, attrs ...interface{}) { ) } -func Warn(msg string, attrs ...interface{}) { +func Warn(operation, correlationID, msg string, attrs ...interface{}) { L.Log.Log( L.Ctx, slog.LevelWarn, @@ -158,7 +157,7 @@ func Warn(msg string, attrs ...interface{}) { ) } -func Info(msg string, attrs ...interface{}) { +func Info(operation, correlationID, msg string, attrs ...interface{}) { L.Log.Log( L.Ctx, slog.LevelInfo, @@ -167,7 +166,7 @@ func Info(msg string, attrs ...interface{}) { ) } -func Debug(msg string, attrs ...interface{}) { +func Debug(operation, correlationID, msg string, attrs ...interface{}) { L.Log.Log( L.Ctx, slog.LevelDebug, @@ -176,7 +175,7 @@ func Debug(msg string, attrs ...interface{}) { ) } -func Trace(msg string, attrs ...interface{}) { +func Trace(operation, correlationID, msg string, attrs ...interface{}) { L.Log.Log( L.Ctx, LevelTrace, diff --git a/structs.go b/structs.go index 97759b7..9a79ebb 100644 --- a/structs.go +++ b/structs.go @@ -3,6 +3,7 @@ package log import ( "context" "log/slog" + "time" ) // primary struct @@ -14,13 +15,47 @@ type Log struct { // field customization type Customization struct { - Application CustomizationValue - Format string - TimeStamp struct { - Key string - Format string - } - Type CustomizationValue + Application string + Format string + TimeStamp TimeStamp + Type string + MobileApplication MobileApplication + Context RequiredContext + Extra ValueAdd } -type CustomizationValue string +type TimeStamp struct { + Key string + Format string +} + +type MobileApplication struct { + DeviceModel string + DeviceBrand string + OsType string + OsVersion string +} + +type RequiredContext struct { + AuditID string + Channel string + Customer string + DestPort string + HttpMethod string + JvmThread string + RemoteIP string + RequestID string + RequestParams string + ResponseCode int + ResponseTime time.Duration + SessionID string + SubOperation string + Uri string + UserID string +} + +type ValueAdd struct { + Customer string + Product string + RequestDomicile string +}