Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add <formatter>.new/1 #145

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

add <formatter>.new/1 #145

wants to merge 2 commits into from

Conversation

ruslandoga
Copy link

@ruslandoga ruslandoga commented Nov 27, 2024

👋

This PR adds a utility function to create formatters. Similar to Logger.Formatter.new/1

Some other ideas for this PR:

  • duplicate docs for each new/1 to make it easier to use, right now the users need to know that there is a "Shared options" section in the LoggerJSON moduledoc, and I think people are usually too lazy to look for it :)
  • add warnings on invalid options passed to new/1
  • extra type specs on new/1?

lib/logger_json.ex Outdated Show resolved Hide resolved
@ruslandoga ruslandoga changed the title add <formatter>.new add <formatter>.new/1 Nov 27, 2024
README.md Show resolved Hide resolved
@@ -22,7 +22,8 @@ defmodule LoggerJSONTest do
end

test "raises on invalid log level" do
message = "Log level should be one of 'debug', 'info', 'warn', 'error' values, got: :invalid"
message =
"Log level should be one of [:error, :info, :debug, :emergency, :alert, :critical, :warning, :notice] values, got: :invalid"
Copy link
Author

@ruslandoga ruslandoga Nov 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can split this change into a separate PR if needed :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant