From 77a16d41f6517ae919a5defce005957e1641d4c5 Mon Sep 17 00:00:00 2001 From: shaharz Date: Mon, 9 Sep 2024 20:20:31 +0100 Subject: [PATCH] Ranch translator: `crash_reason` should be a two-element tuple (#102) See https://github.com/elixir-lang/elixir/blob/5137c33098a2413649bd77cb2e634d00972fde7b/lib/logger/lib/logger.ex#L130). --- lib/plug/cowboy/translator.ex | 2 +- test/plug/cowboy/translator_test.exs | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/plug/cowboy/translator.ex b/lib/plug/cowboy/translator.ex index 28a4923..169b202 100644 --- a/lib/plug/cowboy/translator.ex +++ b/lib/plug/cowboy/translator.ex @@ -61,7 +61,7 @@ defmodule Plug.Cowboy.Translator do extra, " terminated\n" | Exception.format_exit({reason, stack}) - ], crash_reason: reason, domain: [:cowboy]} + ], crash_reason: {reason, stack}, domain: [:cowboy]} end defp log_exception?({%{__exception__: true} = exception, _}) do diff --git a/test/plug/cowboy/translator_test.exs b/test/plug/cowboy/translator_test.exs index 3d44ca4..d416df1 100644 --- a/test/plug/cowboy/translator_test.exs +++ b/test/plug/cowboy/translator_test.exs @@ -131,7 +131,7 @@ defmodule Plug.Cowboy.TranslatorTest do refute metadata =~ "conn: %Plug.Conn{" end - test "metadata in ranch/cowboy lined logs" do + test "metadata in ranch/cowboy linked logs" do {:ok, _pid} = Plug.Cowboy.http(__MODULE__, [], port: 9005) metadata = @@ -141,6 +141,7 @@ defmodule Plug.Cowboy.TranslatorTest do end) assert metadata =~ "crash_reason:" + assert metadata =~ "{GenServer, :call" assert metadata =~ "domain: [:cowboy]" end end