-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created a CustomLogfmtEx to aprse root and bits metadate and be able …
…to adde the root to the logs
- Loading branch information
Showing
3 changed files
with
23 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
defmodule CustomLogfmtEx do | ||
@moduledoc """ | ||
Custom logger formatter for logfmt output. | ||
""" | ||
|
||
alias LambdaEthereumConsensus.Utils | ||
|
||
def format(level, message, timestamp, metadata) do | ||
formatted_metadata = format_metadata(metadata) | ||
|
||
LogfmtEx.format(level, message, timestamp, formatted_metadata) | ||
end | ||
|
||
defp format_metadata(metadata) do | ||
metadata | ||
|> Keyword.replace_lazy(:root, &Utils.format_shorten_binary(&1)) | ||
|> Keyword.replace_lazy(:bits, &Utils.format_bitstring(&1)) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters