Skip to content

Commit

Permalink
HexDocs and prepare RC.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Ruoss committed Oct 31, 2022
1 parent 765dcff commit c7448a8
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

<!-- No new entries below this line! -->

## [1.0.0-rc.1] - 2022-10-31

# Added

- Better logs in case of errors while applying status, descendants or events
- Integration tests for these logs

## [1.0.0-rc.0] - 2022-10-29

### Changed
Expand Down
16 changes: 10 additions & 6 deletions lib/bonny/pluggable/logger.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@ defmodule Bonny.Pluggable.Logger do
@moduledoc """
A pluggable step for logging basic action event information in the format:
{:add, "example.com/v1", "Widget"} - Processing event
{:add, "example.com/v1", "Widget"} - Status applied
{:add, "example.com/v1", "Widget"} - Normal event emitted
{:add, "example.com/v1", "Widget"} - Descendant {"v1", "Deployment", "default/nginx"} applied
{"NAMESPACE/OBJECT_NAME", API_VERSION, "Kind=KIND, Action=ACTION"}
Example:
{"default/my-object", "example.com/v1", "Kind=MyCustomResource, Action=:add"} - Processing event
{"default/my-object", "example.com/v1", "Kind=MyCustomResource, Action=:add"} - Applying status
{"default/my-object", "example.com/v1", "Kind=MyCustomResource, Action=:add"} - Emitting Normal event
{"default/my-object", "example.com/v1", "Kind=MyCustomResource, Action=:add"} - Applying descendant {"default/nginx", "apps/v1", "Kind=Deployment"}
To use it, just add a step to the desired module.
Expand Down Expand Up @@ -56,7 +60,7 @@ defmodule Bonny.Pluggable.Logger do
Logger.log(
level,
fn ->
inspect(id) <> " - Descendant #{inspect(gvkn)} applied"
inspect(id) <> " - Applying descendant #{inspect(gvkn)}"
end,
resource: axn.resource,
descendant: descendant
Expand All @@ -69,7 +73,7 @@ defmodule Bonny.Pluggable.Logger do
Logger.log(
level,
fn ->
inspect(id) <> " - #{event.event_type} event emitted"
inspect(id) <> " - Emitting #{event.event_type} event"
end,
resource: axn.resource,
event: event
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
defmodule Bonny.MixProject do
use Mix.Project
@version "1.0.0-rc.0"
@version "1.0.0-rc.1"
@source_url "https://github.com/coryodaniel/bonny"

def project do
Expand Down
4 changes: 2 additions & 2 deletions test/bonny/pluggable/logger_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ defmodule Bonny.Pluggable.LoggerTest do
end)

assert captured_log =~
~s|{"default/foo", "example.com/v1", "Kind=Widget, Action=:add"} - Descendant {"default/bar", "example.com/v1", "Kind=Cog"} applied|
~s|{"default/foo", "example.com/v1", "Kind=Widget, Action=:add"} - Applying descendant {"default/bar", "example.com/v1", "Kind=Cog"}|
end

test "logs when events are emitted", %{axn: axn} do
Expand All @@ -111,6 +111,6 @@ defmodule Bonny.Pluggable.LoggerTest do
end)

assert captured_log =~
~s|{"default/foo", "example.com/v1", "Kind=Widget, Action=:add"} - Normal event emitted|
~s|{"default/foo", "example.com/v1", "Kind=Widget, Action=:add"} - Emitting Normal event|
end
end

0 comments on commit c7448a8

Please sign in to comment.