merlimat commented on issue #12: package logrus for project
URL: https://github.com/apache/pulsar-client-go/pull/12#issuecomment-493313080
 
 
   > Our main point of disagreement is, in what form the log is output. I 
prefer the latter, that is, re-implement the formatter method, customize our 
own log output format, and package the log into a lib for use by other modules.
   
   I think the log format is not up to us to decide 😄  . Since we're building a 
library, we need to leave it the users of our library, the applications, to 
decide which format they want. 
   
   Logrus seems it does a very good job at a few key things: 
    * Application can decide the formatting of logs. All the library it depends 
on, that are using Logrus, will immediately get configured.
    * Structured logging. This makes the log message much more organized. This 
is especially critical if an application wants to write logs in JSON format 
(which is trivial with Logrus), eg. for getting them into ElasticSearch or 
similar.
   
   > If, in the current way, we need to add the log field to most of the 
structs defined in the future, this will make things difficult.
   
   I think it makes the logs very consistent and organized. Every log message 
printed by the producer controller should contain the context of, for example, 
the topic name. As I mentioned above, in the refactoring you were already using 
3 different ways to pass the topic name within few lines of code, while many 
other log message were missing the topic name context.
   This is normal, and we've been fighting around this in Java for long time, 
since we're constrained to Slf4J APIs. 
   
   Setting the context in the logger itself and storing it in the 
producer/consumer/connection/..., makes it easier to not forget the context and 
always have the same format.
   
   > Use logrus lib print:
   > time="2019-05-17T09:58:37+08:00" level=info msg="hello logrus"
   
   This gets printed when it's not on a terminal.
   
   > Printed log information after rewriting the Formatter:
   > 2019/05/17 10:00:25.530 test.go:9: [info] hello log
   
   If we use Logrus as it is, the users will be able to decide which format 
text vs json, and which fields in which order to present. This looks more 
powerful than any default setting we can put as default.

----------------------------------------------------------------
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]


With regards,
Apache Git Services

Reply via email to