-
Notifications
You must be signed in to change notification settings - Fork 402
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
log level returned by getLevel function in custom logger not being respected. #1812
Comments
Hi @jtoronto, thanks for taking the time to write in! With given information, I am still unsure about the situation you mention. Simply passing logger does not cause it. Could you share code snippet reproducing the issue? |
Sure. The 'logger' here is a Pino instance.
Additionally if I pass in When the boltJS client starts up, it immediately calls Any incoming events also fire several debug messages like If the log level is set to INFO those messages should not be called at all. |
Looking at the built-in This is something that should be documented. |
Thanks for sharing the code. If I understand correctly, your logger implementation needs to sync the log level with the underlying pino logger like this: const pinoLogger = require('pino')();
// You can set log level to the underlying logger
pinoLogger.level = 'info';
// You can pass this logger to App constructor
const logger: Logger = {
debug: (...msgs) => pinoLogger.debug(msgs),
info: (...msgs) => pinoLogger.info(msgs),
warn: (...msgs) => pinoLogger.warn(msgs),
error: (...msgs) => pinoLogger.error(msgs),
setLevel: (_level) => {
// TODO
},
getLevel: () => {
// as long as the string is compatible with @slack/logger,
// just returning the value works for this method
return pinoLogger.level;
},
setName: (_name) => {
// TODO
},
}; I think that Logger interface is still valid while it may be helpful to add more examples to the document. |
No I don't believe that will help, because when you pass in a logger, any When passing in a custom logger, the value returned from the getLevel method gets set to a variable but doesn't actually get used. It's pretty clear here: There is no logic here for "if log message is less than current log level" and it needs to be implemented by you if you're passing in a custom logger. That's fine but the documentation needs to reflect that. |
👋 It looks like this issue has been open for 30 days with no activity. We'll mark this as stale for now, and wait 10 days for an update or for further comment before closing this issue out. If you think this issue needs to be prioritized, please comment to get the thread going again! Maintainers also review issues marked as stale on a regular basis and comment or adjust status if the issue needs to be reprioritized. |
This seems like a legit gap in the From my perspective, I believe to address this issue, the following needs to be done:
|
(Filling out the following with as much detail as you can provide will help us solve your issue sooner.)
Reproducible in:
The Slack SDK version
"slack/bolt": "^3.13.0",
Node.js runtime version
v18.14.0
OS info
Steps to reproduce:
(Share the commands to run, source code, and project settings)
logger
to thenew App()
constructorgetLevel
method returninfo
as the log level.Expected result:
boltJS client should log at INFO level.
Actual result:
Logging at the DEBUG level.
It seems like it's ignoring the value returned by
getLevel()
. I verified that the function is being called and is returninginfo
by using breakpoints, and that it's calling my logger'sdebug
function when logging the above messages. TheThe logLevel given to OAuth was ignored as you also gave logger
are also somewhat confusing.Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you are agreeing to those rules.
The text was updated successfully, but these errors were encountered: