# `Baby.Util`
[🔗](https://github.com/mwmiller/baby_ex/blob/main/lib/baby/util.ex#L1)

Utility functions for use across the codebase

# `connection_log`

Standardised connection activity logging for the supplied state
  `dir`: `:in`, `:out`, `:both`
  `msg`: a protocol message type atom
  `level`: log lvel atom (default: `:debug`)

# `host_to_ip`

A simple wrapper to convert a host binary into an IP tuple

# `log_fatal`

Logging of fatal errors takes connection info and the error

Returns `:error`

# `period_to_ms`

```elixir
@spec period_to_ms({integer(), atom()}) :: integer() | :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

# `range_points`

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([])
    []

---

*Consult [api-reference.md](api-reference.md) for complete listing*
