Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

建议将 mirai-console (backend) 中 org.slf4j.spi.SLF4JServiceProvider 文件 移动至 移动至 frontend #2443

Closed
cssxsh opened this issue Jan 20, 2023 · 3 comments · Fixed by #2701
Labels
M 优先级: 主要 s:console 子系统: mirai-console t:feature 类型: 新特性
Milestone

Comments

@cssxsh
Copy link
Contributor

cssxsh commented Jan 20, 2023

org.slf4j.spi.SLF4JServiceProvider 是指 SPI 服务声明文件
mirai-console/backend/mirai-console/resources/META-INF/services/org.slf4j.spi.SLF4JServiceProvider

net.mamoe.mirai.console.internal.logging.externalbind.slf4j.MiraiConsoleSLF4JService

因为 net.mamoe.mirai.console.internal.logging.externalbind.slf4j.MiraiConsoleSLF4JService
需要 mirai-console frontend 的存在才能正常工作(初始化)

在某些没有 frontend 的环境中,例如单元测试,MiraiConsoleSLF4JService 会影响 SLF4 日志框架 的正常执行

@cssxsh cssxsh added the t:feature 类型: 新特性 label Jan 20, 2023
@Him188 Him188 added N 优先级: 一般 s:console 子系统: mirai-console labels Feb 1, 2023
@Him188 Him188 added this to the Backlog milestone Feb 1, 2023
@Him188
Copy link
Member

Him188 commented Feb 1, 2023

@Karlatemp 你觉得重要么

@cssxsh
Copy link
Contributor Author

cssxsh commented Feb 1, 2023

@Karlatemp 你觉得重要么

这甚至导致了单元测试里 内存溢出
因为 SLF4JServiceProvider 在 mirai-console 没有 初始化的时候会吃掉所有等级的全部日志,等待 mirai-console 初始化再放出
如果用到 netty 这种大量日志的库
很快就炸了

@Him188 Him188 added M 优先级: 主要 and removed N 优先级: 一般 labels Feb 1, 2023
@cssxsh
Copy link
Contributor Author

cssxsh commented Feb 2, 2023

@Him188
顺便再说一下 mirai-console 是默认包括在 由 gradle 插件 构建的插件开发环境中的

也就是说,2.14.0-RC 中 不特殊配置是没有任何 slf4j 日志打印,而且会有内存溢出的可能性

原因是 MiraiConsoleSLF4JService 加载的顺序在 slf4j-simple 之前,且没有 mirai-console 实例加载时不可用

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
M 优先级: 主要 s:console 子系统: mirai-console t:feature 类型: 新特性
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants