     else
       quote do
         case Logger.__should_log__(unquote(level), __MODULE__) do
-          nil -> :ok
-          level -> Logger.__do_log__(level, unquote(data), unquote(quoted_metadata))
+          nil ->
+            :ok
+
+          level ->
+            Logger.__do_log__(
+              level,
+              unquote(data),
+              unquote(Macro.escape(location)),
+              unquote(quoted_metadata)
+            )
         end
       end
     end


  defp compile_time_application_and_file(%{file: file}) do
    if app = Application.get_env(:logger, :compile_time_application) do
      [application: app, file: file |> Path.relative_to_cwd() |> String.to_charlist()]
    else
      [file: String.to_charlist(file)]
    end
  end


  end

  defp macro_log(level, data, metadata, caller) do
    {maybe_application, file} = compile_time_application_and_file(caller)

    location =
      case caller do
        %{module: module, function: {fun, arity}, line: line} ->
          %{mfa: {module, fun, arity}, file: file, line: line}

        _ ->
          %{}
      end

    {compile_metadata, quoted_metadata} =
      if Keyword.keyword?(metadata) do
        metadata = Keyword.merge(maybe_application, metadata)
        {Map.merge(location, Map.new(metadata)), escape_metadata(metadata)}
      else
        {%{},
         quote do
           Enum.into(unquote(metadata), unquote(escape_metadata(maybe_application)))
         end}
      end

