From ff9133b978edb637081882e7efd49e2f538e9e15 Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Tue, 19 Nov 2019 16:01:17 -0600 Subject: [PATCH 1/6] Allow mix tasks to always run with debug logging --- config/config.exs | 1 + config/prod.exs | 2 +- config/test.exs | 2 +- lib/mix/pleroma.ex | 1 + 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/config/config.exs b/config/config.exs index bf2b3f6e2..9ac78c589 100644 --- a/config/config.exs +++ b/config/config.exs @@ -180,6 +180,7 @@ # Configures Elixir's Logger config :logger, :console, + level: :debug, format: "$time $metadata[$level] $message\n", metadata: [:request_id] diff --git a/config/prod.exs b/config/prod.exs index 9c205cbd2..301d2b9cb 100644 --- a/config/prod.exs +++ b/config/prod.exs @@ -20,7 +20,7 @@ config :phoenix, serve_endpoints: true # Do not print debug messages in production -config :logger, level: :warn +config :logger, :console, level: :warn # ## SSL Support # diff --git a/config/test.exs b/config/test.exs index da2778aa7..559ff423e 100644 --- a/config/test.exs +++ b/config/test.exs @@ -15,7 +15,7 @@ method: Pleroma.Captcha.Mock # Print only warnings and errors during test -config :logger, level: :warn +config :logger, :console, level: :warn config :pleroma, :auth, oauth_consumer_strategies: [] diff --git a/lib/mix/pleroma.ex b/lib/mix/pleroma.ex index faeb30e1d..94eeb7d68 100644 --- a/lib/mix/pleroma.ex +++ b/lib/mix/pleroma.ex @@ -6,6 +6,7 @@ defmodule Mix.Pleroma do @doc "Common functions to be reused in mix tasks" def start_pleroma do Application.put_env(:phoenix, :serve_endpoints, false, persistent: true) + Application.put_env(:logger, :console, level: :debug) {:ok, _} = Application.ensure_all_started(:pleroma) end From cb513a599cc3211e6f5e5d1a1710ec2ae85ec37a Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Tue, 19 Nov 2019 16:21:30 -0600 Subject: [PATCH 2/6] Allow test builds to have info and debug logs stripped --- config/test.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/test.exs b/config/test.exs index 559ff423e..da2778aa7 100644 --- a/config/test.exs +++ b/config/test.exs @@ -15,7 +15,7 @@ method: Pleroma.Captcha.Mock # Print only warnings and errors during test -config :logger, :console, level: :warn +config :logger, level: :warn config :pleroma, :auth, oauth_consumer_strategies: [] From 1c17f1832983a784156118d1cd488bfde88f092b Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Wed, 20 Nov 2019 09:14:27 -0600 Subject: [PATCH 3/6] Be specific about format for logs in test as we have tests that check it --- config/test.exs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/config/test.exs b/config/test.exs index da2778aa7..f8188b9e4 100644 --- a/config/test.exs +++ b/config/test.exs @@ -15,7 +15,9 @@ method: Pleroma.Captcha.Mock # Print only warnings and errors during test -config :logger, level: :warn +config :logger, + level: :warn, + format: "[$level] $message" config :pleroma, :auth, oauth_consumer_strategies: [] From c65190c799b6217dca36f9fe4768024b50b725a8 Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Wed, 20 Nov 2019 11:18:42 -0600 Subject: [PATCH 4/6] Console backend's log format should be prefixed and suffixed with newlines. This is how upstream does it by default. --- config/config.exs | 2 +- config/test.exs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/config.exs b/config/config.exs index 9ac78c589..1e36d3314 100644 --- a/config/config.exs +++ b/config/config.exs @@ -181,7 +181,7 @@ # Configures Elixir's Logger config :logger, :console, level: :debug, - format: "$time $metadata[$level] $message\n", + format: "\n$time $metadata[$level] $message\n", metadata: [:request_id] config :logger, :ex_syslogger, diff --git a/config/test.exs b/config/test.exs index f8188b9e4..07e70dd4d 100644 --- a/config/test.exs +++ b/config/test.exs @@ -17,7 +17,7 @@ # Print only warnings and errors during test config :logger, level: :warn, - format: "[$level] $message" + format: "\n[$level] $message\n" config :pleroma, :auth, oauth_consumer_strategies: [] From edaae845afc63d558c22019b3b3f87bc510a3bdf Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Wed, 20 Nov 2019 11:55:30 -0600 Subject: [PATCH 5/6] Some tasks try to set log level in test environment, but we were stripping logs belog :warn. Ensure console backend logs in test environment are :warn, but mix tasks run in test env do not run with :debug because it's far too verbose. --- config/test.exs | 2 +- lib/mix/pleroma.ex | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/config/test.exs b/config/test.exs index 07e70dd4d..9b737d4d7 100644 --- a/config/test.exs +++ b/config/test.exs @@ -15,7 +15,7 @@ method: Pleroma.Captcha.Mock # Print only warnings and errors during test -config :logger, +config :logger, :console, level: :warn, format: "\n[$level] $message\n" diff --git a/lib/mix/pleroma.ex b/lib/mix/pleroma.ex index 94eeb7d68..73a076a53 100644 --- a/lib/mix/pleroma.ex +++ b/lib/mix/pleroma.ex @@ -6,7 +6,11 @@ defmodule Mix.Pleroma do @doc "Common functions to be reused in mix tasks" def start_pleroma do Application.put_env(:phoenix, :serve_endpoints, false, persistent: true) - Application.put_env(:logger, :console, level: :debug) + + if Pleroma.Config.get(:env) != :test do + Application.put_env(:logger, :console, level: :debug) + end + {:ok, _} = Application.ensure_all_started(:pleroma) end From 320690f7a5bf1622e25114b6ad4c0b0c5a252748 Mon Sep 17 00:00:00 2001 From: lain Date: Thu, 21 Nov 2019 14:03:01 +0100 Subject: [PATCH 6/6] Object: Use inspect to log missing preload. --- lib/pleroma/object.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pleroma/object.ex b/lib/pleroma/object.ex index d9b41d710..cde0eddd9 100644 --- a/lib/pleroma/object.ex +++ b/lib/pleroma/object.ex @@ -63,7 +63,7 @@ def get_by_ap_id(ap_id) do end defp warn_on_no_object_preloaded(ap_id) do - "Object.normalize() called without preloaded object (#{ap_id}). Consider preloading the object" + "Object.normalize() called without preloaded object (#{inspect(ap_id)}). Consider preloading the object" |> Logger.debug() Logger.debug("Backtrace: #{inspect(Process.info(:erlang.self(), :current_stacktrace))}")