Skip to content

Commit

Permalink
fix took field in log response
Browse files Browse the repository at this point in the history
  • Loading branch information
os-esh committed Oct 16, 2023
1 parent f36883f commit 742dbd6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ElasticsearchClient"
uuid = "e586a49d-aa29-4ce5-8f91-fa4f824367bd"
authors = ["Egor Shmorgun <[email protected]>"]
version = "0.2.10"
version = "0.2.11"

[deps]
CodecZlib = "944b1d66-785c-5afd-91f1-9de20f533193"
Expand Down
6 changes: 3 additions & 3 deletions src/elastic_transport/transport/transport.jl
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,8 @@ function perform_request(

if !isempty(response_body) && !isnothing(response_content_type) && !isnothing(match(r"json"i, response_content_type))
json = transport.deserializer(response_body)
took = if json isa Dict
get(json, "took", "n/a")
if json isa AbstractDict
took = get(() -> get(json, :took, "n/a"), json, "took")
end
end

Expand Down Expand Up @@ -302,7 +302,7 @@ end
function log_response(method, body, url, response_status, response_body, took, duration, verbose; message_level=Logging.Info)
sanitized_url = replace(url, r"//(.+):(.+)@" => s"//\1:$SANITIZED_PASSWORD@")
log_message(
"$(uppercase(method)) $sanitized_url [status:$(response_status), request:$(duration), query:$(took)]",
"$(uppercase(method)) $sanitized_url [status:$(response_status), request:$(duration), elastic query: $(took)]",
message_level,
verbose
)
Expand Down

0 comments on commit 742dbd6

Please sign in to comment.