LoggerBinary CI

A custom Logger formatter for handling binary data.

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

Usage

def deps do
[
{:logger_binary, "~> 0.1.0"}
]
end
config :logger, LoggerBinary.Formatter, format: "[$level] $message\n"
config :logger, :console,
format: {LoggerBinary.Formatter, :format},
metadata: [:direction]

Features

Direction Indicator

You can add the :direction metadata to your log messages to indicate if the binary data is an incoming or outgoing message:

Logger.debug(<<0x01, 0x02, 0x03>>, direction: :in)
# Logs: "[debug] < 01 02 03"
Logger.debug(<<0x01, 0x02, 0x03>>, direction: :out)
# Logs: "[debug] > 01 02 03"

Without directional metadata, it simply logs the formatted binary:

Logger.debug(<<0x01, 0x02, 0x03>>)
# Logs: "[debug] 01 02 03"