Packages

Set of Credo checks that improve your logging

Current section

Files

Jump to
credo_logging README.md
Raw

README.md

<!--
SPDX-FileCopyrightText: 2026 Łukasz Niemier <~@hauleth.dev>

SPDX-License-Identifier: Apache-2.0
-->

# Credo Logging

Checks to help with proper logger usage.

- `CredoLogging.NonStructuredLog` - check if there is non-structured message
  passed as a log message
- `CredoLogging.ReportCb` - check if there are structured log messages without
  accompanying `:report_cb` callback. It also check whether specified callback
  is a remote function capture.

## Installation

The package can be installed by adding `credo_logging` to your list of
dependencies in `mix.exs`:

```elixir
def deps do
  [
    {:credo_logging, "~> 0.1.0"}
  ]
end
```

And then add to your `.credo.exs`:

```elixir
%{
  # …
  checks: %{
    enabled: [
      # …
      {CredoLogging.NonStructuredLog, []},
      {CredoLogging.ReportCb, []}
    ]
    # …
  }
}
```

Documentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc)
and published on [HexDocs](https://hexdocs.pm). Once published, the docs can
be found at <https://hexdocs.pm/credo_logging>.