Skip to content

Commit 3ef99bc

Browse files
committed
Address review comments
1 parent 76df110 commit 3ef99bc

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

integration_test/sql/logging.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ defmodule Ecto.Integration.LoggingTest do
139139
end) =~ stacktrace_entry(__ENV__.line)
140140

141141
out = capture_log(fn ->
142-
TestRepo.all(Post, Keyword.put(@stacktrace_opts, :log_stacktrace_mfa, {Ecto.Adapters.SQL, :last_non_ecto_stacktrace, [2]}))
142+
TestRepo.all(Post, Keyword.put(@stacktrace_opts, :log_stacktrace_mfa, {Ecto.Adapters.SQL, :first_non_ecto_stacktrace, [2]}))
143143

144144
:ok
145145
end)

lib/ecto/adapters/sql.ex

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -869,7 +869,7 @@ defmodule Ecto.Adapters.SQL do
869869
log = Keyword.get(config, :log, :debug)
870870

871871
log_stacktrace_mfa =
872-
Keyword.get(config, :log_stacktrace_mfa, {__MODULE__, :last_non_ecto_stacktrace, [1]})
872+
Keyword.get(config, :log_stacktrace_mfa, {__MODULE__, :first_non_ecto_stacktrace, [1]})
873873

874874
if log not in @valid_log_levels do
875875
raise """
@@ -1399,9 +1399,9 @@ defmodule Ecto.Adapters.SQL do
13991399
end
14001400

14011401
defp log_stacktrace([_ | _] = stacktrace, repo, {module, function, args}) do
1402-
entries = apply(module, function, args ++ [Enum.reverse(stacktrace), repo])
1402+
entries = apply(module, function, [stacktrace, repo | args])
14031403

1404-
for {{module, function, arity, info}, idx} <- Enum.with_index(entries) do
1404+
Enum.with_index(entries, fn {module, function, arity, info}, idx ->
14051405
[
14061406
?\n,
14071407
IO.ANSI.light_black(),
@@ -1411,7 +1411,7 @@ defmodule Ecto.Adapters.SQL do
14111411
log_stacktrace_info(info),
14121412
IO.ANSI.reset()
14131413
]
1414-
end
1414+
end)
14151415
end
14161416

14171417
defp log_stacktrace(_, _, _), do: []
@@ -1426,8 +1426,9 @@ defmodule Ecto.Adapters.SQL do
14261426

14271427
@repo_modules [Ecto.Repo.Queryable, Ecto.Repo.Schema, Ecto.Repo.Transaction]
14281428

1429-
def last_non_ecto_stacktrace(size, stacktrace, repo) do
1429+
def first_non_ecto_stacktrace(stacktrace, repo, size) do
14301430
stacktrace
1431+
|> Enum.reverse()
14311432
|> last_non_ecto_entries(repo, [])
14321433
|> Enum.take(size)
14331434
end

0 commit comments

Comments
 (0)