Skip to content

Commit

Permalink
Rename Logger to IntegrationLogger
Browse files Browse the repository at this point in the history
In order to implement the Logger that comunicates with the Logging API
in the agent, the integration internal logger is renamed to Integration
Logger. This is based in the Ruby and Node.js implementation.
  • Loading branch information
luismiramirez committed Nov 15, 2022
1 parent c29cbf6 commit cb143d7
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 31 deletions.
14 changes: 7 additions & 7 deletions lib/appsignal.ex
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ defmodule Appsignal do

@doc false
def stop(_state) do
Appsignal.Logger.debug("AppSignal stopping.")
Appsignal.IntegrationLogger.debug("AppSignal stopping.")
end

@doc false
Expand All @@ -69,12 +69,12 @@ defmodule Appsignal do
Logger.info("AppSignal disabled.")

{:ok, true} ->
Appsignal.Logger.debug("AppSignal starting.")
Appsignal.IntegrationLogger.debug("AppSignal starting.")
Config.write_to_environment()
Appsignal.Nif.start()

if Appsignal.Nif.loaded?() do
Appsignal.Logger.debug("AppSignal started.")
Appsignal.IntegrationLogger.debug("AppSignal started.")
else
log_nif_loading_error()
end
Expand Down Expand Up @@ -154,12 +154,12 @@ defmodule Appsignal do
{install_arch, install_target} = fetch_installed_architecture_target()

if arch == install_arch && target == install_target do
Appsignal.Logger.error(
Appsignal.IntegrationLogger.error(
"AppSignal failed to load the extension. Please run the diagnose tool and email us at support@appsignal.com: https://docs.appsignal.com/elixir/command-line/diagnose.html\n",
stderr: true
)
else
Appsignal.Logger.error(
Appsignal.IntegrationLogger.error(
"The AppSignal NIF was installed for architecture '#{install_arch}-#{install_target}', but the current architecture is '#{arch}-#{target}'. Please reinstall the AppSignal package on the host the app is started: mix deps.compile appsignal --force",
stderr: true
)
Expand All @@ -176,7 +176,7 @@ defmodule Appsignal do
{parse_architecture(arch), target}

{:error, reason} ->
Appsignal.Logger.error(
Appsignal.IntegrationLogger.error(
"Failed to parse the AppSignal 'install.report' file: #{inspect(reason)}",
stderr: true
)
Expand All @@ -185,7 +185,7 @@ defmodule Appsignal do
end

{:error, reason} ->
Appsignal.Logger.error(
Appsignal.IntegrationLogger.error(
"Failed to read the AppSignal 'install.report' file: #{inspect(reason)}",
stderr: true
)
Expand Down
2 changes: 1 addition & 1 deletion lib/appsignal/ecto.ex
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ defmodule Appsignal.Ecto do

case :telemetry.attach({__MODULE__, event}, event, &__MODULE__.handle_event/4, :ok) do
:ok ->
Appsignal.Logger.debug("Appsignal.Ecto attached to #{inspect(event)}")
Appsignal.IntegrationLogger.debug("Appsignal.Ecto attached to #{inspect(event)}")

{:error, _} = error ->
Logger.warn("Appsignal.Ecto not attached to #{inspect(event)}: #{inspect(error)}")
Expand Down
2 changes: 1 addition & 1 deletion lib/appsignal/error/backend.ex
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ defmodule Appsignal.Error.Backend do
def attach do
case Logger.add_backend(Appsignal.Error.Backend) do
{:error, error} -> Logger.warn("Appsignal.Error.Backend not attached to Logger: #{error}")
_ -> Appsignal.Logger.debug("Appsignal.Error.Backend attached to Logger")
_ -> Appsignal.IntegrationLogger.debug("Appsignal.Error.Backend attached to Logger")
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/appsignal/finch.ex
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ defmodule Appsignal.Finch do
for {event, fun} <- handlers do
case :telemetry.attach({__MODULE__, event}, event, fun, :ok) do
:ok ->
_ = Appsignal.Logger.debug("Appsignal.Finch attached to #{inspect(event)}")
_ = Appsignal.IntegrationLogger.debug("Appsignal.Finch attached to #{inspect(event)}")

:ok

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
defmodule Appsignal.Logger do
defmodule Appsignal.IntegrationLogger do
require Appsignal.Utils

@io Appsignal.Utils.compile_env(:appsignal, :io, IO)
Expand Down
2 changes: 1 addition & 1 deletion lib/appsignal/monitor.ex
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ defmodule Appsignal.Monitor do

pids = MapSet.new(monitored_pids())

Appsignal.Logger.debug(
Appsignal.IntegrationLogger.debug(
"Synchronizing monitored PIDs in Appsignal.Monitor (#{MapSet.size(pids)})"
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
defmodule Appsignal.LoggerTest do
defmodule Appsignal.IntegrationLoggerTest do
import AppsignalTest.Utils
use ExUnit.Case

Expand All @@ -11,11 +11,11 @@ defmodule Appsignal.LoggerTest do

test "all methods log messages when config log level is trace" do
with_config(%{log_level: "trace"}, fn ->
Appsignal.Logger.trace("trace!")
Appsignal.Logger.debug("debug!")
Appsignal.Logger.info("info!")
Appsignal.Logger.warn("warning!")
Appsignal.Logger.error("error!")
Appsignal.IntegrationLogger.trace("trace!")
Appsignal.IntegrationLogger.debug("debug!")
Appsignal.IntegrationLogger.info("info!")
Appsignal.IntegrationLogger.warn("warning!")
Appsignal.IntegrationLogger.error("error!")
end)

until(fn -> assert FakeFile.count() == 5 end)
Expand All @@ -39,11 +39,11 @@ defmodule Appsignal.LoggerTest do

test "only error method logs messages when config log level is error" do
with_config(%{log_level: "error"}, fn ->
Appsignal.Logger.trace("trace!")
Appsignal.Logger.debug("debug!")
Appsignal.Logger.info("info!")
Appsignal.Logger.warn("warning!")
Appsignal.Logger.error("error!")
Appsignal.IntegrationLogger.trace("trace!")
Appsignal.IntegrationLogger.debug("debug!")
Appsignal.IntegrationLogger.info("info!")
Appsignal.IntegrationLogger.warn("warning!")
Appsignal.IntegrationLogger.error("error!")
end)

until(fn -> assert FakeFile.count() == 1 end)
Expand All @@ -54,7 +54,7 @@ defmodule Appsignal.LoggerTest do

test "logs info message when config log level is debug" do
with_config(%{log_level: "debug"}, fn ->
Appsignal.Logger.info("info!")
Appsignal.IntegrationLogger.info("info!")
end)

until(fn -> assert FakeFile.count() == 1 end)
Expand All @@ -65,7 +65,7 @@ defmodule Appsignal.LoggerTest do

test "logs debug message when config log level is debug" do
with_config(%{log_level: "debug"}, fn ->
Appsignal.Logger.debug("debug!")
Appsignal.IntegrationLogger.debug("debug!")
end)

until(fn -> assert FakeFile.count() == 1 end)
Expand All @@ -76,15 +76,15 @@ defmodule Appsignal.LoggerTest do

test "does not log trace message when config log level is debug" do
with_config(%{log_level: "debug"}, fn ->
Appsignal.Logger.trace("trace!")
Appsignal.IntegrationLogger.trace("trace!")
end)

repeatedly(fn -> assert FakeFile.count() == 0 end)
end

test "logs to file by default" do
with_config(%{}, fn ->
Appsignal.Logger.info("info!")
Appsignal.IntegrationLogger.info("info!")
end)

until(fn ->
Expand All @@ -100,7 +100,7 @@ defmodule Appsignal.LoggerTest do

test "logs to stdout when config log is stdout" do
with_config(%{log: "stdout"}, fn ->
Appsignal.Logger.info("info!")
Appsignal.IntegrationLogger.info("info!")
end)

until(fn ->
Expand All @@ -115,7 +115,7 @@ defmodule Appsignal.LoggerTest do

test "logs to stderr instead of stdout when stderr is set" do
with_config(%{log: "stdout"}, fn ->
Appsignal.Logger.warn("warning!", stderr: true)
Appsignal.IntegrationLogger.warn("warning!", stderr: true)
end)

until(fn ->
Expand All @@ -130,7 +130,7 @@ defmodule Appsignal.LoggerTest do

test "logs to stderr and to file when stderr is set" do
with_config(%{}, fn ->
Appsignal.Logger.warn("warning!", stderr: true)
Appsignal.IntegrationLogger.warn("warning!", stderr: true)
end)

until(fn ->
Expand All @@ -154,7 +154,7 @@ defmodule Appsignal.LoggerTest do
on_exit(fn -> File.rm_rf("/tmp/foo") end)

with_config(%{log_path: "/tmp/foo"}, fn ->
Appsignal.Logger.warn("warning!")
Appsignal.IntegrationLogger.warn("warning!")
end)

until(fn -> assert FakeFile.count() == 1 end)
Expand Down

0 comments on commit cb143d7

Please sign in to comment.