You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a suggestion to make Honeydew.Logger a behaviour to allow custom adapters for it.
The reasoning is that depending on the job nature for crash handle, you can easily get overwhelmed with a lot of log warn messages that are very verbose like this one:
This change would allow the user to create a custom adapter for the Honeydew log messages so he can filter some messages out or modify it to be less verbose.
The implementation could be something like this:
defmoduleHoneydew.LoggerdoaliasHoneydew.{Crash,Job}@callbackworker_init_crashed(module,Crash.t()):::ok@callbackjob_failed(Job.t(),Crash.t()):::okenddefmoduleHoneydew.Logger.DefaultAdapterdo@moduledocfalsealiasHoneydew.CrashaliasHoneydew.Logger.MetadataaliasHoneydew.JobrequireLogger@behaviourHoneydew.Logger@implHoneydew.Loggerdefworker_init_crashed(module,%Crash{type: :exception,reason: exception}=crash)doLogger.warn(fn->{"#{module}.init/1 must return {:ok, state :: any()}, but raised #{inspect(exception)}",honeydew_crash_reason: Metadata.build_crash_reason(crash)}end)enddefworker_init_crashed(module,%Crash{type: :throw,reason: thrown}=crash)doLogger.warn(fn->{"#{module}.init/1 must return {:ok, state :: any()}, but threw #{inspect(thrown)}",honeydew_crash_reason: Metadata.build_crash_reason(crash)}end)enddefworker_init_crashed(module,%Crash{type: :bad_return_value,reason: value}=crash)doLogger.warn(fn->{"#{module}.init/1 must return {:ok, state :: any()}, got: #{inspect(value)}",honeydew_crash_reason: Metadata.build_crash_reason(crash)}end)end@implHoneydew.Loggerdefjob_failed(%Job{}=job,%Crash{type: :exception}=crash)doLogger.warn(fn->{""" Job failed due to exception. #{inspect(job)}#{format_crash_for_log(crash)} """,honeydew_crash_reason: Metadata.build_crash_reason(crash),honeydew_job: job}end)enddefjob_failed(%Job{}=job,%Crash{type: :throw}=crash)doLogger.warn(fn->{""" Job failed due to uncaught throw. #{inspect(job)}",#{format_crash_for_log(crash)} """,honeydew_crash_reason: Metadata.build_crash_reason(crash),honeydew_job: job}end)enddefjob_failed(%Job{}=job,%Crash{type: :exit}=crash)doLogger.warn(fn->{""" Job failed due unexpected exit. #{inspect(job)}",#{format_crash_for_log(crash)} """,honeydew_crash_reason: Metadata.build_crash_reason(crash),honeydew_job: job}end)enddefpformat_crash_for_log(%Crash{type: :exception,reason: exception,stacktrace: stacktrace})doException.format(:error,exception,stacktrace)enddefpformat_crash_for_log(%Crash{type: :throw,reason: exception,stacktrace: stacktrace})doException.format(:throw,exception,stacktrace)enddefpformat_crash_for_log(%Crash{type: :exit,reason: reason,stacktrace: []})doException.format(:exit,reason,[])endend
And the user can configure it when starting the queue:
Hello,
This is a suggestion to make
Honeydew.Logger
a behaviour to allow custom adapters for it.The reasoning is that depending on the job nature for crash handle, you can easily get overwhelmed with a lot of log warn messages that are very verbose like this one:
This change would allow the user to create a custom adapter for the
Honeydew
log messages so he can filter some messages out or modify it to be less verbose.The implementation could be something like this:
And the user can configure it when starting the queue:
The text was updated successfully, but these errors were encountered: