Skip to content

Commit

Permalink
chore: improve logger docs
Browse files Browse the repository at this point in the history
fixes #671

Signed-off-by: Yordis Prieto <[email protected]>
  • Loading branch information
yordis committed Oct 25, 2024
1 parent 6f0f2c0 commit 1fca7c3
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions lib/tesla/middleware/logger.ex
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ defmodule Tesla.Middleware.Logger do
@moduledoc ~S"""
Log requests using Elixir's Logger.
With the default settings it logs request method, URL, response status, and time taken in milliseconds.
With the default settings it logs request method, URL, response status, and
time taken in milliseconds.
## Examples
Expand All @@ -77,7 +78,7 @@ defmodule Tesla.Middleware.Logger do
- `:log_level` - custom function for calculating log level (see below)
- `:filter_headers` - sanitizes sensitive headers before logging in debug mode (see below)
- `:debug` - show detailed request/response logging
- `:debug` - use `Logger.debug/2` to log request/response details
- `:format` - custom string template or function for log message (see below)
## Custom log format
Expand Down Expand Up @@ -140,12 +141,18 @@ defmodule Tesla.Middleware.Logger do
## Logger Debug output
When the Elixir Logger log level is set to `:debug`
Tesla Logger will show full request & response.
`Tesla` will use `Logger.debug/2` to log request & response details using
the `:debug` option. It will require to set the `Logger` log level to `:debug`
in your configuration, example:
If you want to disable detailed request/response logging
but keep the `:debug` log level (i.e. in development)
you can set `debug: false` in your config:
```elixir
# config/dev.exs
config :logger, level: :debug
```
If you want to disable detailed request/response logging but keep the
`:debug` log level (i.e. in development) you can set `debug: false` in your
config:
```elixir
# config/dev.local.exs
Expand Down

0 comments on commit 1fca7c3

Please sign in to comment.