bschofield opened a new pull request #436:
URL: https://github.com/apache/pulsar-client-go/pull/436


   ### Motivation
   
   This client library has pluggable logging and a bridge to the popular 
_logrus_ library. Currently, there is no bridge to the (also popular) _zap_ 
logging library.
   
   This PR adds a bridge to _zap_.
   
   ### Usage
   
   Assume you have set up your logger at program init time, e.g.
   
       logger, err = zap.NewProduction()
       if err != nil {
           log.Fatalf("failed to set up zap: %v", err)
       }
   
       zap.ReplaceGlobals(logger)
   
   Then, when creating a client, add the _zap_ sugared logger like this:
   
       client := pulsar.NewClient(pulsar.ClientOptions{
           URL:    pulsarURL,
           Logger: log.NewLoggerWithZap(zap.S()),
       })
   
   where `log` is the package `github.com/apache/pulsar-client-go/pulsar/log`.
   
   ### Modifications
   
   Added a new `zapWrapper` type to the `log` package.
   
   This does introduce a dependency on _zap_. If that is undesirable, it might 
be simpler to put the `wrapper_zap.go` code (which is quite short) in the 
documentation somewhere. However, you already have a dependency on _logrus_, so 
an additional dependency on another very common logging library doesn't seem so 
bad to me.
   
   ### Verifying this change
   
   This change is a trivial rework / code cleanup without any test coverage.
   
   ### Does this pull request potentially affect one of the following parts:
   
   *If `yes` was chosen, please highlight the changes*
   
     - Dependencies (does it add or upgrade a dependency): yes
     - The public API: no
     - The schema: no
     - The default values of configurations: no
     - The wire protocol: no
   
   ### Documentation
   
     - Does this pull request introduce a new feature? yes
     - If yes, how is the feature documented? GoDocs
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to