From 9a8cdc4031c3b253f8a308b6212e9958473f870f Mon Sep 17 00:00:00 2001 From: Luke Imhoff Date: Wed, 29 Aug 2018 09:15:52 -0500 Subject: [PATCH] Use Path.absname so that log paths are stable during reload Fixes #628 The Phoenix.CodeReloader causes the file loggers to restart and reload their config, but when they reload, the current working directory has shifted from the project root to the OTP app root, so it produces log files under each OTP app (`apps/APP_NAME/logs`). We don't want this, so compute the absolute path in the config files, so that the loaded `Application` environment has an absolute path in it that can't shift when the working directory changes. --- apps/block_scout_web/config/dev.exs | 2 +- apps/block_scout_web/config/prod.exs | 2 +- apps/block_scout_web/config/test.exs | 2 +- apps/ethereum_jsonrpc/config/dev.exs | 2 +- apps/ethereum_jsonrpc/config/prod.exs | 2 +- apps/ethereum_jsonrpc/config/test.exs | 2 +- apps/explorer/config/dev.exs | 2 +- apps/explorer/config/prod.exs | 2 +- apps/explorer/config/test.exs | 2 +- apps/indexer/config/dev.exs | 2 +- apps/indexer/config/prod.exs | 2 +- apps/indexer/config/test.exs | 2 +- config/dev.exs | 4 ++-- config/prod.exs | 4 ++-- config/test.exs | 4 ++-- 15 files changed, 18 insertions(+), 18 deletions(-) diff --git a/apps/block_scout_web/config/dev.exs b/apps/block_scout_web/config/dev.exs index a3b83689d4..d821ac555f 100644 --- a/apps/block_scout_web/config/dev.exs +++ b/apps/block_scout_web/config/dev.exs @@ -50,7 +50,7 @@ config :block_scout_web, BlockScoutWeb.Endpoint, config :logger, :block_scout_web, level: :debug, - path: "logs/dev/block_scout_web.log" + path: Path.absname("logs/dev/block_scout_web.log") # Set a higher stacktrace during development. Avoid configuring such # in production as building large stacktraces may be expensive. diff --git a/apps/block_scout_web/config/prod.exs b/apps/block_scout_web/config/prod.exs index 723a756e72..2ee9f44976 100644 --- a/apps/block_scout_web/config/prod.exs +++ b/apps/block_scout_web/config/prod.exs @@ -26,4 +26,4 @@ config :block_scout_web, BlockScoutWeb.Endpoint, config :logger, :block_scout_web, level: :info, - path: "logs/prod/block_scout_web.log" + path: Path.absname("logs/prod/block_scout_web.log") diff --git a/apps/block_scout_web/config/test.exs b/apps/block_scout_web/config/test.exs index 39316171e5..d9737d55c7 100644 --- a/apps/block_scout_web/config/test.exs +++ b/apps/block_scout_web/config/test.exs @@ -11,7 +11,7 @@ config :block_scout_web, BlockScoutWeb.Endpoint, config :logger, :block_scout_web, level: :warn, - path: "logs/test/block_scout_web.log" + path: Path.absname("logs/test/block_scout_web.log") # Configure wallaby config :wallaby, screenshot_on_failure: true diff --git a/apps/ethereum_jsonrpc/config/dev.exs b/apps/ethereum_jsonrpc/config/dev.exs index 4f58c751fb..1e5d0ebbe4 100644 --- a/apps/ethereum_jsonrpc/config/dev.exs +++ b/apps/ethereum_jsonrpc/config/dev.exs @@ -2,4 +2,4 @@ use Mix.Config config :logger, :ethereum_jsonrpc, level: :debug, - path: "logs/dev/ethereum_jsonrpc.log" + path: Path.absname("logs/dev/ethereum_jsonrpc.log") diff --git a/apps/ethereum_jsonrpc/config/prod.exs b/apps/ethereum_jsonrpc/config/prod.exs index 4f9bda8052..84d1142f93 100644 --- a/apps/ethereum_jsonrpc/config/prod.exs +++ b/apps/ethereum_jsonrpc/config/prod.exs @@ -2,4 +2,4 @@ use Mix.Config config :logger, :ethereum_jsonrpc, level: :info, - path: "logs/prod/ethereum_jsonrpc.log" + path: Path.absname("logs/prod/ethereum_jsonrpc.log") diff --git a/apps/ethereum_jsonrpc/config/test.exs b/apps/ethereum_jsonrpc/config/test.exs index 5911d7c7c9..d066e4a38a 100644 --- a/apps/ethereum_jsonrpc/config/test.exs +++ b/apps/ethereum_jsonrpc/config/test.exs @@ -2,4 +2,4 @@ use Mix.Config config :logger, :ethereum_jsonrpc, level: :warn, - path: "logs/test/ethereum_jsonrpc.log" + path: Path.absname("logs/test/ethereum_jsonrpc.log") diff --git a/apps/explorer/config/dev.exs b/apps/explorer/config/dev.exs index 2cf332eab3..d6363c383c 100644 --- a/apps/explorer/config/dev.exs +++ b/apps/explorer/config/dev.exs @@ -11,7 +11,7 @@ config :explorer, Explorer.Repo, config :logger, :explorer, level: :debug, - path: "logs/dev/explorer.log" + path: Path.absname("logs/dev/explorer.log") import_config "dev.secret.exs" diff --git a/apps/explorer/config/prod.exs b/apps/explorer/config/prod.exs index 6a3156ac3c..de2fbca77f 100644 --- a/apps/explorer/config/prod.exs +++ b/apps/explorer/config/prod.exs @@ -11,7 +11,7 @@ config :explorer, Explorer.Repo, config :logger, :explorer, level: :info, - path: "logs/prod/explorer.log" + path: Path.absname("logs/prod/explorer.log") variant = if is_nil(System.get_env("ETHEREUM_JSONRPC_VARIANT")) do diff --git a/apps/explorer/config/test.exs b/apps/explorer/config/test.exs index 18e805d293..f816e3edc4 100644 --- a/apps/explorer/config/test.exs +++ b/apps/explorer/config/test.exs @@ -19,7 +19,7 @@ config :explorer, Explorer.Market.History.Cataloger, enabled: false config :logger, :explorer, level: :warn, - path: "logs/test/explorer.log" + path: Path.absname("logs/test/explorer.log") if File.exists?(file = "test.secret.exs") do import_config file diff --git a/apps/indexer/config/dev.exs b/apps/indexer/config/dev.exs index 0ee948b0fc..902d015fde 100644 --- a/apps/indexer/config/dev.exs +++ b/apps/indexer/config/dev.exs @@ -2,7 +2,7 @@ use Mix.Config config :logger, :indexer, level: :debug, - path: "logs/dev/indexer.log" + path: Path.absname("logs/dev/indexer.log") variant = if is_nil(System.get_env("ETHEREUM_JSONRPC_VARIANT")) do diff --git a/apps/indexer/config/prod.exs b/apps/indexer/config/prod.exs index 8377cc8330..a71c7648dd 100644 --- a/apps/indexer/config/prod.exs +++ b/apps/indexer/config/prod.exs @@ -2,7 +2,7 @@ use Mix.Config config :logger, :indexer, level: :info, - path: "logs/prod/indexer.log" + path: Path.absname("logs/prod/indexer.log") variant = if is_nil(System.get_env("ETHEREUM_JSONRPC_VARIANT")) do diff --git a/apps/indexer/config/test.exs b/apps/indexer/config/test.exs index e4e228d2b7..be30aae684 100644 --- a/apps/indexer/config/test.exs +++ b/apps/indexer/config/test.exs @@ -2,4 +2,4 @@ use Mix.Config config :logger, :indexer, level: :warn, - path: "logs/test/indexer.log" + path: Path.absname("logs/test/indexer.log") diff --git a/config/dev.exs b/config/dev.exs index 0adbc43d60..7f8759b576 100644 --- a/config/dev.exs +++ b/config/dev.exs @@ -5,6 +5,6 @@ config :logger, :console, level: :info config :logger, :ecto, level: :debug, - path: "logs/dev/ecto.log" + path: Path.absname("logs/dev/ecto.log") -config :logger, :error, path: "logs/dev/error.log" +config :logger, :error, path: Path.absname("logs/dev/error.log") diff --git a/config/prod.exs b/config/prod.exs index dd889fd400..fadd9254f5 100644 --- a/config/prod.exs +++ b/config/prod.exs @@ -6,6 +6,6 @@ config :logger, :console, level: :info config :logger, :ecto, level: :info, - path: "logs/prod/ecto.log" + path: Path.absname("logs/prod/ecto.log") -config :logger, :error, path: "logs/prod/error.log" +config :logger, :error, path: Path.absname("logs/prod/error.log") diff --git a/config/test.exs b/config/test.exs index ad540e2b99..77b8675ef9 100644 --- a/config/test.exs +++ b/config/test.exs @@ -6,9 +6,9 @@ config :logger, :console, level: :warn config :logger, :ecto, level: :warn, - path: "logs/test/ecto.log" + path: Path.absname("logs/test/ecto.log") -config :logger, :error, path: "logs/test/error.log" +config :logger, :error, path: Path.absname("logs/test/error.log") config :explorer, Explorer.ExchangeRates, source: Explorer.ExchangeRates.Source.NoOpSource,