Skip to content

Commit 5d4eeed

Browse files
committed
Update docs
1 parent 56a2ebc commit 5d4eeed

File tree

2 files changed

+33
-42
lines changed

2 files changed

+33
-42
lines changed

README.md

Lines changed: 33 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,52 +2,49 @@
22

33
A custom `Logger` formatter for handling binary data.
44

5-
This formatter is designed to correctly format binary messages. It converts
6-
non-printable binary data into a hexadecimal string representation and can
7-
optionally add a directional indicator (`"< "` or `"> "`) when needed.
5+
This formatter is designed to correctly format binary messages. It converts
6+
non-printable binary data into a hexadecimal string representation and can
7+
optionally add a directional indicator (`"< "` or `"> "`) when needed.
88

9-
## Usage
9+
## Usage
1010

11-
config :logger, :console,
12-
format: {LoggerBinary.Formatter, :format},
13-
metadata: [:direction]
14-
15-
## Features
16-
17-
* Formats binary messages as uppercase hexadecimal strings.
18-
* Prepends formatted binary messages with a directional indicator if the `:direction`
19-
metadata is present. Supported values for the `:direction` metadata are `:in` and `:out`.
20-
* Uses the default Logger format for all other types of messages (e.g., printable strings and charlists).
11+
```elixir
12+
def deps do
13+
[
14+
{:logger_binary, "~> 0.1.0"}
15+
]
16+
end
17+
```
2118

22-
## Direction Indicator
19+
```elixir
20+
config :logger, :console,
21+
format: {LoggerBinary.Formatter, :format},
22+
metadata: [:direction]
23+
```
2324

24-
You can add the `:direction` metadata to your log messages to indicate if the
25-
binary data is an incoming or outgoing message:
25+
## Features
2626

27-
Logger.debug(<<0x01, 0x02, 0x03>>, direction: :in)
28-
# Logs: "[debug] < 01 02 03"
27+
* Formats binary messages as uppercase hexadecimal strings.
28+
* Prepends formatted binary messages with a directional indicator if the `:direction`
29+
metadata is present. Supported values for the `:direction` metadata are `:in` and `:out`.
30+
* Uses the default Logger format for all other types of messages (e.g., printable strings and charlists).
2931

30-
Logger.debug(<<0x01, 0x02, 0x03>>, direction: :out)
31-
# Logs: "[debug] > 01 02 03"
32+
## Direction Indicator
3233

33-
Without directional metadata, it simply logs the formatted binary:
34+
You can add the `:direction` metadata to your log messages to indicate if the
35+
binary data is an incoming or outgoing message:
3436

35-
Logger.debug(<<0x01, 0x02, 0x03>>)
36-
# Logs: "[debug] 01 02 03"
37+
```elixir
38+
Logger.debug(<<0x01, 0x02, 0x03>>, direction: :in)
39+
# Logs: "[debug] < 01 02 03"
3740

38-
## Installation
41+
Logger.debug(<<0x01, 0x02, 0x03>>, direction: :out)
42+
# Logs: "[debug] > 01 02 03"
43+
```
3944

40-
If [available in Hex](https://hex.pm/docs/publish), the package can be installed
41-
by adding `logger_binary` to your list of dependencies in `mix.exs`:
45+
Without directional metadata, it simply logs the formatted binary:
4246

4347
```elixir
44-
def deps do
45-
[
46-
{:logger_binary, "~> 0.1.0"}
47-
]
48-
end
48+
Logger.debug(<<0x01, 0x02, 0x03>>)
49+
# Logs: "[debug] 01 02 03"
4950
```
50-
51-
Documentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc)
52-
and published on [HexDocs](https://hexdocs.pm). Once published, the docs can
53-
be found at <https://hexdocs.pm/logger_binary>.

lib/logger_binary.ex

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@ defmodule LoggerBinary do
66
non-printable binary data into a hexadecimal string representation and can
77
optionally add a directional indicator (`"< "` or `"> "`) when needed.
88
9-
## Usage
10-
11-
config :logger, :console,
12-
format: {LoggerBinary.Formatter, :format},
13-
metadata: [:direction]
14-
159
## Features
1610
1711
* Formats binary messages as uppercase hexadecimal strings.

0 commit comments

Comments
 (0)