-
Notifications
You must be signed in to change notification settings - Fork 202
Expand file tree
/
Copy pathlogger_test.exs
More file actions
60 lines (48 loc) · 1.39 KB
/
Copy pathlogger_test.exs
File metadata and controls
60 lines (48 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
defmodule Cluster.LoggerTest do
@moduledoc false
use ExUnit.Case
import ExUnit.CaptureLog
alias Cluster.Logger
Application.put_env(:libcluster, :debug, true)
for level <- [:debug, :info, :warn, :error] do
describe "#{level}/2" do
test "logs correctly" do
output =
capture_log(fn ->
apply(Logger, unquote(level), [
__MODULE__,
"some message"
])
end)
assert output =~ "[#{unquote(level)}]"
assert output =~ "[libcluster:Elixir.Cluster.LoggerTest] some message"
end
end
end
describe "debug_inspect/2" do
setup do
Application.put_env(:libcluster, :debug, 1)
end
test "with label" do
output =
capture_log(fn ->
%{foo: "bar"} |> Logger.debug_inspect(__MODULE__, label: "value")
end)
assert output =~ ~s|[libcluster:Elixir.Cluster.LoggerTest] value: %{foo: "bar"}|
end
test "without label" do
output =
capture_log(fn ->
%{foo: "bar"} |> Logger.debug_inspect(__MODULE__)
end)
assert output =~ ~s|[libcluster:Elixir.Cluster.LoggerTest] %{foo: "bar"}|
end
test "ignore if level is too low" do
output =
capture_log(fn ->
%{foo: "bar"} |> Logger.debug_inspect(__MODULE__, label: "value", verbose: 2)
end)
assert output == ""
end
end
end