Skip to content

Commit 266064e

Browse files
Add ring_logger by default
1 parent a55d377 commit 266064e

File tree

4 files changed

+25
-9
lines changed

4 files changed

+25
-9
lines changed

lib/mix/tasks/nerves/new.ex

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ defmodule Mix.Tasks.Nerves.New do
88
@shoehorn_vsn "0.4"
99
@bootstrap_vsn "1.0"
1010
@runtime_vsn "0.6"
11+
@ring_logger_vsn "0.4"
1112
@init_gadget_vsn "0.4"
1213

1314
@requirement Mix.Project.config()[:elixir]
@@ -167,6 +168,7 @@ defmodule Mix.Tasks.Nerves.New do
167168
bootstrap_vsn: @bootstrap_vsn,
168169
shoehorn_vsn: @shoehorn_vsn,
169170
runtime_vsn: @runtime_vsn,
171+
ring_logger_vsn: @ring_logger_vsn,
170172
elixir_req: @requirement,
171173
nerves_dep: nerves_dep(nerves_path),
172174
in_umbrella: in_umbrella?,

templates/new/config/config.exs

+7-7
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,13 @@ config :nerves, :firmware, rootfs_overlay: "rootfs_overlay"
1414
# involved with firmware updates.
1515
config :shoehorn,
1616
init: [:nerves_runtime<%= if init_gadget? do %>, :nerves_init_gadget<% end %>],
17-
app: Mix.Project.config()[:app]<%= if init_gadget? do %>
17+
app: Mix.Project.config()[:app]
18+
19+
# Use Ringlogger as the logger backend and remove :console.
20+
# See https://hexdocs.pm/ring_logger/readme.html for more information on
21+
# configuring ring_logger.
22+
23+
config :logger, backends: [RingLogger]<%= if init_gadget? do %>
1824

1925
# Authorize the device to receive firmware using your public key.
2026
# See https://hexdocs.pm/nerves_firmware_ssh/readme.html for more information
@@ -29,12 +35,6 @@ config :nerves_firmware_ssh,
2935
File.read!(key)
3036
]
3137

32-
# Use Ringlogger as the logger backend and remove :console.
33-
# See https://hexdocs.pm/ring_logger/readme.html for more information on
34-
# configuring ring_logger.
35-
36-
config :logger, backends: [RingLogger]
37-
3838
# Configure nerves_init_gadget.
3939
# See https://hexdocs.pm/nerves_init_gadget/readme.html for more information.
4040

templates/new/mix.exs

+2-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ defmodule <%= app_module %>.MixProject do
4242
defp deps do
4343
[
4444
<%= nerves_dep %>,
45-
{:shoehorn, "~> <%= shoehorn_vsn %>"}
45+
{:shoehorn, "~> <%= shoehorn_vsn %>"},
46+
{:ring_logger, "~> <%= ring_logger_vsn %>"}
4647
] ++ deps(@target)
4748
end
4849

test/nerves_new_test.exs

+14-1
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,20 @@ defmodule Nerves.NewTest do
101101
end)
102102
end
103103

104+
test "new project includes ring_logger", context do
105+
in_tmp(context.test, fn ->
106+
Mix.Tasks.Nerves.New.run([@app_name])
107+
108+
assert_file("#{@app_name}/mix.exs", fn file ->
109+
assert file =~ ~r":ring_logger"
110+
end)
111+
112+
assert_file("#{@app_name}/config/config.exs", fn file ->
113+
assert file =~ ~r"RingLogger"
114+
end)
115+
end)
116+
end
117+
104118
test "new project init gadget", context do
105119
in_tmp(context.test, fn ->
106120
Mix.Tasks.Nerves.New.run([@app_name, "--init-gadget"])
@@ -112,7 +126,6 @@ defmodule Nerves.NewTest do
112126
assert_file("#{@app_name}/config/config.exs", fn file ->
113127
assert file =~ ~r"nerves_init_gadget"
114128
assert file =~ ~r"nerves_firmware_ssh"
115-
assert file =~ ~r"RingLogger"
116129
end)
117130
end)
118131
end

0 commit comments

Comments
 (0)