Generate URLs for Libravatar and Gravatar avatars
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: improve logging

- Reduce verbosity of cache cleanup logs by logging only if there were
any entries removed.
- Use structured logging with report callbacks for better observability.

+22 -2
+12 -1
lib/aww.ex
··· 140 140 {:ok, ttl, {host, _} = result} -> 141 141 if host in defederated do 142 142 Logger.debug( 143 - "Ignoring avatar from #{host}, because it was defederated" 143 + %{ 144 + kind: :ignore, 145 + reason: :defederated, 146 + host: host, 147 + list: defederated 148 + }, 149 + report_cb: &__MODULE__.__report_cb__/1 144 150 ) 145 151 146 152 {fallback, 60_000} ··· 233 239 catch 234 240 _, _ -> 235 241 :error 242 + end 243 + 244 + @doc false 245 + def __report_cb__(%{kind: :ignore, reason: :defederated, host: host}) do 246 + {"Ignoring avatar from ~p, because it was defederated", [host]} 236 247 end 237 248 end
+10 -1
lib/aww/cache.ex
··· 78 78 {{:_, :_, :"$1"}, [{:"=<", :"$1", timestamp}], [true]} 79 79 ]) 80 80 81 - Logger.debug("Deleted #{count} cached entries") 81 + if count > 0 do 82 + Logger.debug(%{cache: state.name, deleted: count}, 83 + report_cb: &__MODULE__.__report_cb__/1 84 + ) 85 + end 82 86 83 87 Process.send_after(self(), :cleanup, state.cleanup) 84 88 85 89 {:noreply, state} 90 + end 91 + 92 + @doc false 93 + def __report_cb__(%{cache: name, deleted: count}) do 94 + {"Deleted ~B entries from ~p cache", [count, name]} 86 95 end 87 96 end