Baby.Util (Baby v0.34.0)
View SourceUtility functions for use across the codebase
Summary
Functions
Standardised connection activity logging for the supplied state
dir: :in, :out, :both
msg: a protocol message type atom
level: log lvel atom (default: :debug)
A simple wrapper to convert a host binary into an IP tuple
Logging of fatal errors takes connection info and the error
Convert a {count, unit} period into a number of milliseconds
Returns tuples of the endpoints of the widest continuous ranges in a list of integers
Functions
Standardised connection activity logging for the supplied state
dir: :in, :out, :both
msg: a protocol message type atom
level: log lvel atom (default: :debug)
A simple wrapper to convert a host binary into an IP tuple
Logging of fatal errors takes connection info and the error
Returns :error
Convert a {count, unit} period into a number of milliseconds
Examples
iex> Baby.Util.period_to_ms({1, :hour})
3_600_000
iex> Baby.Util.period_to_ms({17, :minute})
1_020_000
Returns tuples of the endpoints of the widest continuous ranges in a list of integers
iex> Baby.Util.range_points([8, 2, 5, 4, 3, 10, 11, 16, 17])
[{2, 5}, {8, 8}, {10, 11}, {16, 17}]
iex> Baby.Util.range_points([127])
[{127, 127}]
iex> Baby.Util.range_points([])
[]