Skip to content

Commit

Permalink
require in function
Browse files Browse the repository at this point in the history
  • Loading branch information
altjohndev committed Jan 7, 2025
1 parent a6ad9d4 commit abe6745
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/logger_json/formatters/basic.ex
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ defmodule LoggerJSON.Formatters.Basic do

if Code.ensure_loaded?(Plug.Conn) do
if @encoder == Jason do
require Jason.Helpers

defp format_http_request(%{conn: %Plug.Conn{} = conn}) do
require Jason.Helpers

Jason.Helpers.json_map(
connection:
Jason.Helpers.json_map(
Expand Down
4 changes: 2 additions & 2 deletions lib/logger_json/formatters/datadog.ex
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,9 @@ defmodule LoggerJSON.Formatters.Datadog do

if Code.ensure_loaded?(Plug.Conn) do
if @encoder == Jason do
require Jason.Helpers

defp build_http_request_data(%Plug.Conn{} = conn, request_id) do
require Jason.Helpers

request_url = Plug.Conn.request_url(conn)
user_agent = Formatter.Plug.get_header(conn, "user-agent")
remote_ip = Formatter.Plug.remote_ip(conn)
Expand Down
4 changes: 2 additions & 2 deletions lib/logger_json/formatters/google_cloud.ex
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,9 @@ defmodule LoggerJSON.Formatters.GoogleCloud do

if Code.ensure_loaded?(Plug.Conn) do
if @encoder == Jason do
require Jason.Helpers

defp format_http_request(%{conn: %Plug.Conn{} = conn} = assigns) do
require Jason.Helpers

request_method = conn.method |> to_string() |> String.upcase()
request_url = Plug.Conn.request_url(conn)
status = conn.status
Expand Down

0 comments on commit abe6745

Please sign in to comment.