forked from thurloat/dough
parent
49b26be43e
commit
c23178c0f0
@ -1,26 +1,33 @@ |
||||
defmodule Dough.RequestContext do |
||||
require Logger |
||||
|
||||
|
||||
defstruct [:start, :close, :lookup, :cache, :ttl] |
||||
|
||||
def ctx_start(ctx) do |
||||
Map.put(ctx, :start, System.monotonic_time(:milliseconds)) |
||||
end |
||||
|
||||
def ctx_close(ctx) do |
||||
Map.put(ctx, :close, System.monotonic_time(:milliseconds)) |
||||
end |
||||
|
||||
def ctx_lookup(ctx, dns_record) do |
||||
Map.put(ctx, :lookup, dns_record.qdlist |> List.first()) |
||||
end |
||||
|
||||
def ctx_cachehit(ctx, v) do |
||||
Map.put(ctx, :cache, v) |
||||
end |
||||
|
||||
def ctx_ttl(ctx, ttl) do |
||||
Map.put(ctx, :ttl, ttl) |
||||
end |
||||
|
||||
def ctx_log_out(ctx) do |
||||
Logger.info "#{ctx.lookup.type} - #{ctx.lookup.domain} - TTL #{ctx.ttl} | #{ctx.cache} - #{ctx.close - ctx.start}ms" |
||||
Logger.info( |
||||
"#{ctx.lookup.type} - #{ctx.lookup.domain} - TTL #{ctx.ttl} | #{ctx.cache} - #{ |
||||
ctx.close - ctx.start |
||||
}ms" |
||||
) |
||||
end |
||||
end |
||||
|
Loading…
Reference in new issue