{"id":16484910,"url":"https://github.com/stephenmoloney/og","last_synced_at":"2025-08-04T02:11:55.417Z","repository":{"id":62430148,"uuid":"51961483","full_name":"stephenmoloney/og","owner":"stephenmoloney","description":"Og is a small collection of logger helper functions in elixir. ","archived":false,"fork":false,"pushed_at":"2017-12-17T12:11:46.000Z","size":51,"stargazers_count":4,"open_issues_count":1,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-03-14T18:35:34.192Z","etag":null,"topics":["debug","debugging","elixir","elixir-lang","inspects","log","logger","logging"],"latest_commit_sha":null,"homepage":"https://hexdocs.pm/og/Og.html","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stephenmoloney.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-02-17T22:53:49.000Z","updated_at":"2024-03-14T18:35:34.193Z","dependencies_parsed_at":"2022-11-01T20:07:26.772Z","dependency_job_id":null,"html_url":"https://github.com/stephenmoloney/og","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stephenmoloney%2Fog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stephenmoloney%2Fog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stephenmoloney%2Fog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stephenmoloney%2Fog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stephenmoloney","download_url":"https://codeload.github.com/stephenmoloney/og/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245104464,"owners_count":20561376,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["debug","debugging","elixir","elixir-lang","inspects","log","logger","logging"],"created_at":"2024-10-11T13:18:41.196Z","updated_at":"2025-03-23T12:32:45.595Z","avatar_url":"https://github.com/stephenmoloney.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Óg [![Build Status](https://travis-ci.org/stephenmoloney/og.svg)](https://travis-ci.org/stephenmoloney/og) [![Hex Version](http://img.shields.io/hexpm/v/og.svg?style=flat)](https://hex.pm/packages/og) [![Hex docs](http://img.shields.io/badge/hex.pm-docs-green.svg?style=flat)](https://hexdocs.pm/og)\n\n[Óg](http://hexdocs.pm/og/Og.html) is a small collection of debugging functions for logging data.\n\n\n### Note\n\n- Functions `Og.log/2` and `Og.log_r/2` are primarily intended as debugging tools.\n\n\n### Installation\n\nAdd óg to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps, do: [{:og, \"~\u003e 1.0\"}]\n```\n\nEnsure that `:logger` is started in the applications:\n\n```elixir\ndef application do [applications: [:logger, :og]] end\n```\n\n## Summary\n\n- `log/2` - logs the data transformed by the inspector function\nand returns `:ok`\n\n\n- `log_r/2` - logs the data transformed by the inspector function\nand returns the original data.\n\n\n- Inspection of the data before logging it can be helpful in a debugging context for\nexample for\n    - Avoiding the `Protocol.UndefinedError` when logging tuples.\n    - Not needing to require Logger\n\n\n- Formatting with `Kernel.inspect` on the data carries an overhead so\n`Og.log/2` and `Og.log_r/2` should be probably be reserved for debugging code in `:dev`\nenvironments.\n\n\n## Configuration\n\n    config :logger, :og,\n      kernel_opts: [width: 70],\n      apex_opts: [numbers: :false, color: :false],\n      sanitize_by_default: :false,\n      default_inspector: :kernel\n\n\n## Configuration options\n\n- `kernel_opts` - corresponds to elixir inspect opts for `IO.inspect/2`\nand `Kernel.inspect/2`, refer to `https://hexdocs.pm/elixir/Inspect.Opts.html`\n\n\n- `apex_opts` - corresponds to options for the `Apex.Format.format/2` function,\nrefer to `https://github.com/BjRo/apex/blob/master/lib/apex/format.ex`\n\n\n- `sanitize_by_default` - defaults to `:false`, when set to `:true`, an attempt will\nbe made to apply the `SecureLogFormatter.sanitize/1` function on the data\nbefore applying the inspection function. For this function to take any\neffect, the settings for `SecureLogFormatter` must also be placed in\n`config.exs`. See the following\n[secure_log_formatter url](https://github.com/localvore-today/secure_log_formatter/blob/master/lib/secure_log_formatter.ex)\nfor more details.\n\n\n- `default_inspector` - corresponds to the default inspector which will apply\nto the data passed to the log function. This can be overriden in the options\nof the log function. The options are `:kernel` or `:apex`, the default is `:kernel`.\n\n\nExample configuration for secure_log_formatter, as referenced at\nthe following [secure_log_formatter url](https://github.com/localvore-today/secure_log_formatter/blob/master/lib/secure_log_formatter.ex).\n\n\n    config :logger,\n      secure_log_formatter:\n        [\n          # Map and Keyword List keys who's value should be hidden\n          fields: [\"password\", \"credit_card\", ~r/.*_token/],\n\n          # Patterns which if found, should be hidden\n          patterns: [~r/4[0-9]{15}/] # Simple credit card example\n\n          # defaults to \"[REDACTED]\"\n          replacement: \"[PRIVATE]\"\n        ]\n\n\n### some examples\n\n\n- Basic logging\n\n```elixir\nOg.log(:this_is_a_test)\n```\n\n- Logging at the `:warn` level\n\n```elixir\nOg.log(:this_is_a_test, level: :warn)\n```\n\n- Logging at the `:warn` level and with __ENV__ specified to get richer information\n\n```elixir\nOg.log(:this_is_a_test, level: :warn, env: __ENV__)\n````\n\n- Logging with the Apex inspector\n\n```elixir\nOg.log(:this_is_a_test, inspector: :apex)\n```\n\n- Logging and applying sanitization with the features of\n[secure_log_formatter](https://github.com/localvore-today/secure_log_formatter)\n\n```elixir\nOg.log(%{credit_card: 4111111111111}, sanitize: :true)\n```\n\n- Logging inside a chain of piped functions\n\n```elixir\ndefmodule OgTest do\n  def log() do\n    %{first: \"john\", last: \"doe\"}\n    |\u003e Map.to_list()\n    |\u003e Enum.filter( \u0026(\u00261 === {:first, \"john\"}))\n    |\u003e Og.log_r()\n    |\u003e List.last()\n    |\u003e Tuple.to_list()\n    |\u003e List.last()\n    |\u003e Og.log_r(env: __ENV__, inspector: :kernel, level: :info)\n    |\u003e String.upcase()\n  end\nend\nOgTest.log()\n```\n\n\n### Dependencies\n\n- [Apex library](https://hex.pm/packages/apex) --- [Björn Rochel](https://hex.pm/users/bjro)\n    - Setting the `config.exs` opts or the log function opts to `inspector: :apex`\n    will use the `Apex.Format.format/2` function from the apex library.\n\n\n- [SecureLogFormatter library](https://hex.pm/packages/secure_log_formatter)  ---  [Sean Callan](https://hex.pm/users/doomspork)\n    - Setting `config.exs` opts or the log function opts to `sanitize: :true`\n    will use the `SecureLogFormatter.sanitize/1` function from the SecureLogFormatter library.\n\n\n### Todo\n\n- [ ] Investigate adding a custom formatting module as an optional additional means of logging.\n\n\n### Licence\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstephenmoloney%2Fog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstephenmoloney%2Fog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstephenmoloney%2Fog/lists"}