From 1fca7c3e8fdcf7e15fd91e7b471098e6cdd01bec Mon Sep 17 00:00:00 2001 From: Yordis Prieto Date: Fri, 25 Oct 2024 14:08:59 -0400 Subject: [PATCH] chore: improve logger docs fixes #671 Signed-off-by: Yordis Prieto --- lib/tesla/middleware/logger.ex | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/lib/tesla/middleware/logger.ex b/lib/tesla/middleware/logger.ex index 0ec06191..c1329590 100644 --- a/lib/tesla/middleware/logger.ex +++ b/lib/tesla/middleware/logger.ex @@ -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 @@ -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 @@ -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