Closed eprothro closed 9 months ago
Sorry I took a long time to reply here...
This is particularly strange... we have tests for exactly this case. Most of the time log levels are evaluated at compile time so, just to be sure, have you tried recompile the dependency once changing the log level?
In any case, I've decided to move away from custom logging in libraries... from Elixir 1.12+ it makes less sense... We can set levels for specific modules or whole applications with Logger.put_application_level/2
and so on.
This will be included in a next major version.
Thanks for the response! That could make sense as our application log level is set a runtime. However as shown above, the joken log level is set at compile time, and I would have expected that to override application level.
Would certainly prefer to see telemetry over application logging!
@eprothro , did you end up sorting it out?
I've tried adding the following line to my runtime.exs
but it had no effect:
Logger.put_module_level(MyApp.MyStrategy, :warning)
I also tried like this (adding the .EtsCache), with no success either:
Logger.put_module_level(MyApp.MyStrategy.EtsCache, :warning)
I also tried those in an iex
session, with no luck.
Then I gave up trying to change it during runtime and tried to set it in my config.exs
, with no luck again:
config :logger,
compile_time_purge_matching: [
[module: MyApp.MyStrategy, level_lower_than: :warning]
]
Same thing with .EtsCache
.
I'm not familiar with macros, so I also tried those with JokenJwks.DefaultStrategyTemplate.EtsCache
instead because not sure what happens first. But no luck either. Any help would be much appreciated.
@rogerweb nope still cluttering our logs, just hasn't been the priority.
I will look at it more closely now. Sorry for the long delay in support here... I have a complete pure Elixir JOSE replacement for JWS and was half way through JWE but life just took all my time in the last months...
I will see if I can reproduce locally, fix it and release a new version ASAP.
I've opened #47 . Can any of you try it before releasing a new version?
Can any of you try it before releasing a new version?
Successfully tested within my application, capturing the following events:
[:joken_jwks, :default_strategy, :signers],
[:joken_jwks, :http_fetcher, :start],
[:joken_jwks, :http_fetcher, :stop]
Couldn't test the other two though:
[:joken_jwks, :default_strategy, :refetch],
[:joken_jwks, :http_fetcher, :exception]
Thanks for the quick turn around!
:refetch
should trigger when you send a bad token... try feeding the api something like "a.b.c"
and see if it trigges then.
:exception
will only trigger if the http channel somehow raises (like :econnrefused
and friends)
Managed to trigger the :refetch
but no success simulating the :exception
. Tried 3 scenarios only:
(1) network cable unplugged (2) invalid domain in the JWKS URL (3) JWKS URL returning 404
(1) and (2) resulted in an error message in the log but no telemetry event:
[error] Failed to fetch signers. Reason: {:error, :nxdomain}
(3) resulted in an error message in the log but no telemetry event:
[error] Failed to fetch signers. Reason: {:error, :jwks_client_http_error}
I'm fine with the current behavior.
Thanks for trying it out @rogerweb . I will add some test cases here and merge it :)
The new approach with telemetry is on master (which I will rename to main non next release) and will be on next release.
Thanks all for the input!
Regardless of either of the documented configurations for log level:
The logs emitted follow the
Logger.level
, debug shown below: