Git Product home page Git Product logo

Comments (8)

qqxx6661 avatar qqxx6661 commented on August 13, 2024

给线程池来处理发送日志的逻辑(不管是发送到本地就处理还是给消息队列),好处是主线程不会因为发送逻辑而阻塞,因为很多时候处理日志的逻辑是很快的,而发送rocketMq等等,要等网络时延,其实反而是更耗时的步骤。

主线程来处理发送日志的逻辑,优点是ThreadLocal也就是LogRecordContext还在,之前有issue提出想在发送的逻辑上取LogRecordContext的值,如果用线程池来发送,那上下文就丢了。不过在发送的时候还去取上下文这种做法不推荐。

我等于是把选择抛给了用户,可以选用线程池或者是主线程来处理发送逻辑。

from log-record.

GitHubZkLn avatar GitHubZkLn commented on August 13, 2024

明白了,我看代码的逻辑应该是,如果在配置文件里配置了线程池,则发送日志的逻辑用线程池,否则用主线程来发送是吧?那这就意味着是不是用哪一种都行呢,都可以实现功能呢?

我是刚入职的小白,最近在做这个模块,感觉你做的挺好的。 我还有点不明白 “如果用线程池来发送,那上下文就丢了” 这是什么意思。

还想问一下,我如果直接等解析完日志,然后直接把日志对象存入库中,是不是就不用什么线程池啥的,用主线程就可以了?

from log-record.

qqxx6661 avatar qqxx6661 commented on August 13, 2024

明白了,我看代码的逻辑应该是,如果在配置文件里配置了线程池,则发送日志的逻辑用线程池,否则用主线程来发送是吧?那这就意味着是不是用哪一种都行呢,都可以实现功能呢?

我是刚入职的小白,最近在做这个模块,感觉你做的挺好的。 我还有点不明白 “如果用线程池来发送,那上下文就丢了” 这是什么意思。

还想问一下,我如果直接等解析完日志,然后直接把日志对象存入库中,是不是就不用什么线程池啥的,用主线程就可以了?

只是本地落数据库的话,两种都可以,什么配置都不动就行。所有工具都应该贯彻”约定大于配置“的理念,除非有特殊场景,尽量不让使用者做复杂的配置。

from log-record.

GitHubZkLn avatar GitHubZkLn commented on August 13, 2024

只能落本地数据库吗,不能存线上数据库吗,还想问一下,如果加注解的那个接口调用失败了,还会有响应的日志信息被收集到吗

from log-record.

qqxx6661 avatar qqxx6661 commented on August 13, 2024

只能落本地数据库吗,不能存线上数据库吗,还想问一下,如果加注解的那个接口调用失败了,还会有响应的日志信息被收集到吗

和本地线上没关系,都可以。接口失败的话,会有抛出的异常信息被收集到,正常的返回信息拿不到(都没有返回信息了)

from log-record.

GitHubZkLn avatar GitHubZkLn commented on August 13, 2024

好的,明白了。我看日志模块中还增加了diff功能,还想问一下这个功能在什么场景下使用的,没看懂diff是用来干嘛的,我看测试模块当中好像也没用到

from log-record.

qqxx6661 avatar qqxx6661 commented on August 13, 2024

好的,明白了。我看日志模块中还增加了diff功能,还想问一下这个功能在什么场景下使用的,没看懂diff是用来干嘛的,我看测试模块当中好像也没用到

有些时候需要对比两个对象里面的值差异,比如有的系统支持修改用户信息,就会有这种日志:

【用户工号】从【1】变成了【2】 【name】从【张三】变成了【李四】

这个你仔细看下文档就ok得,我觉得我写的算是清楚了。

from log-record.

GitHubZkLn avatar GitHubZkLn commented on August 13, 2024

好的,谢谢楼主

from log-record.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.