Óg Build StatusHex VersionHex docs

Óg is a small collection of debugging functions for logging data.

Note

Installation

Add óg to your list of dependencies in mix.exs:

def deps, do: [{:og, "~> 1.0"}]

Ensure that :logger is started in the applications:

def application do [applications: [:logger, :og]] end

Summary

Configuration

config :logger, :og,
  kernel_opts: [width: 70],
  apex_opts: [numbers: :false, color: :false],
  sanitize_by_default: :false,
  default_inspector: :kernel

Configuration options

Example configuration for secure_log_formatter, as referenced at the following secure_log_formatter url.

config :logger,
  secure_log_formatter:
    [
      # Map and Keyword List keys who's value should be hidden
      fields: ["password", "credit_card", ~r/.*_token/],

      # Patterns which if found, should be hidden
      patterns: [~r/4[0-9]{15}/] # Simple credit card example

      # defaults to "[REDACTED]"
      replacement: "[PRIVATE]"
    ]

some examples

Og.log(:this_is_a_test)
Og.log(:this_is_a_test, level: :warn)
Og.log(:this_is_a_test, level: :warn, env: __ENV__)
````

- Logging with the Apex inspector

Og.log(:this_is_a_test, inspector: :apex)


- Logging inside a chain of piped functions

defmodule OgTest do def log() do

%{first: "john", last: "doe"}
|> Map.to_list()
|> Enum.filter( &(&1 === {:first, "john"}))
|> Og.log_r()
|> List.last()
|> Tuple.to_list()
|> List.last()
|> Og.log_r(env: __ENV__, inspector: :kernel, level: :info)
|> String.upcase()

end end OgTest.log()



### Acknowledgements

- [Apex library](https://hex.pm/packages/apex), [Björn Rochel](https://hex.pm/users/bjro)
    - Setting the `config.exs` opts or the log function opts to `inspector: :apex`
    will use the `Apex.Format.format/2` function from the apex library.


- [SecureLogFormatter library](https://hex.pm/packages/secure_log_formatter), [Sean Callan](https://hex.pm/users/doomspork)
    - Setting `config.exs` opts or the log function opts to `sanitize: :true`
    will use the `SecureLogFormatter.sanitize/1` function from the SecureLogFormatter library.


### Todo

- [ ] Investigate adding a custom formatting module as an optional additional means of logging.


### Licence

MIT