@@ -88,8 +88,7 @@ can be changed by calling chainable methods.
8888
8989``` go
9090server := NewServer (" amqp://guest:guest@localhost:5672" ).
91- WithDebugLogger (log.Printf ).
92- WithErrorLogger (log.Printf ).
91+ WithLogger (logger).
9392 WithTLS (&tls.Config {})
9493```
9594
@@ -115,10 +114,10 @@ request := NewRequest().
115114
116115response, err := client.Send(request)
117116if err != nil {
118- log.Fatal (err.Error())
117+ slog.Error (err.Error())
119118}
120119
121- log.Print (string(response.Body))
120+ slog.Info (string(response.Body))
122121```
123122
124123The client will not connect while being created, instead this happens when the
@@ -139,8 +138,7 @@ Example of available methods for chaining.
139138
140139``` go
141140client := NewClient (" amqp://guest:guest@localhost:5672" ).
142- WithDebugLogger (log.Printf ).
143- WithErrorLogger (log.Printf ).
141+ WithLogger (logger).
144142 WithDialConfig (amqp.Config {}).
145143 WithTLS (&tls.Config {}).
146144 WithReplyToConsumerArgs (amqp.Table {}).
@@ -399,24 +397,30 @@ server.ListenAndServe()
399397
400398## Logging
401399
402- You can specify two optional loggers for debugging and errors or unexpected
403- behaviour. By default only error logging is turned on and is logged via the log
404- package's standard logging.
400+ You can specify your own ` slog.Logger ` instance. By default amqp-rpc will log
401+ errors using the logger from ` slog.Default() ` . Some logs will contain data
402+ contained in a ` amqp.Delivery ` or ` amqp.Publishing ` , including any headers. If
403+ you want to avoid logging some of the fields you can use an ` slog.Handler ` to
404+ filter out the fields you don't want to log.
405405
406- You can provide your own logging function for both error and debug on both the
407- client and the server.
406+ The library will log using two different levels: ` slog.LevelDebug ` and
407+ ` slog.LevelInfo ` .
408+
409+ If you want to use something other than ` slog ` for logging, you can implement a
410+ ` slog.Handler ` wrapper that wraps your preferred logging implementation.
408411
409412``` go
410- debugLogger := log.New (os.Stdout , " DEBUG - " , log.LstdFlags )
411- errorLogger := log.New (os.Stdout , " ERROR - " , log.LstdFlags )
413+ logger := slog.New (
414+ slog.NewTextHandler (os.Stdout , &slog.HandlerOptions {
415+ Level : slog.LevelDebug ,
416+ }),
417+ )
412418
413419server := NewServer (url).
414- WithErrorLogger (errorLogger.Printf ).
415- WithDebugLogger (debugLogger.Printf )
420+ WithLogger (logger)
416421
417422client := NewClient (url).
418- WithErrorLogger (errorLogger.Printf ).
419- WithDebugLogger (debugLogger.Printf )
423+ WithLogger (logger)
420424```
421425
422426This is perfect when using a logger which supports debugging as a separate
0 commit comments