PreHook logs the notification before processing and allows modification.
(ctx context.Context, notificationCtx push.NotificationHandlerContext, notificationType string, notification []interface{})
| 17 | |
| 18 | // PreHook logs the notification before processing and allows modification. |
| 19 | func (lh *LoggingHook) PreHook(ctx context.Context, notificationCtx push.NotificationHandlerContext, notificationType string, notification []interface{}) ([]interface{}, bool) { |
| 20 | if lh.LogLevel >= 2 { // Info level |
| 21 | // Log the notification type and content |
| 22 | connID := uint64(0) |
| 23 | if conn, ok := notificationCtx.Conn.(*pool.Conn); ok { |
| 24 | connID = conn.GetID() |
| 25 | } |
| 26 | seqID := int64(0) |
| 27 | if slices.Contains(maintenanceNotificationTypes, notificationType) { |
| 28 | // seqID is the second element in the notification array |
| 29 | if len(notification) > 1 { |
| 30 | if parsedSeqID, ok := notification[1].(int64); !ok { |
| 31 | seqID = 0 |
| 32 | } else { |
| 33 | seqID = parsedSeqID |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | } |
| 38 | internal.Logger.Printf(ctx, logs.ProcessingNotification(connID, seqID, notificationType, notification)) |
| 39 | } |
| 40 | return notification, true // Continue processing with unmodified notification |
| 41 | } |
| 42 | |
| 43 | // PostHook logs the result after processing. |
| 44 | func (lh *LoggingHook) PostHook(ctx context.Context, notificationCtx push.NotificationHandlerContext, notificationType string, notification []interface{}, result error) { |
nothing calls this directly
no test coverage detected