Skip to content

Commit

Permalink
use custom logger. #386
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Jan 16, 2020
1 parent 6f3d4e8 commit 2012e81
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions app/controllers/works_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def index
end

begin
logger = Logger.new(STDOUT)
logger.warn "[Benchmark] Elasticsearch request " + response.took.to_s + " ms"

total = response.results.total
Expand All @@ -69,6 +70,7 @@ def index
clients = total > 0 ? facet_by_client(response.response.aggregations.clients.buckets) : nil
affiliations = total > 0 ? facet_by_affiliation(response.response.aggregations.affiliations.buckets) : nil
}
logger = Logger.new(STDOUT)
logger.warn "[Benchmark Warning] aggregations " + bma.to_s + " ms"

@dois = response.results
Expand Down Expand Up @@ -111,6 +113,7 @@ def index
bmr = Benchmark.ms {
render json: WorkSerializer.new(@dois, options).serialized_json, status: :ok
}
logger = Logger.new(STDOUT)
logger.warn "[Benchmark] render " + bmr.to_s + " ms"
rescue Elasticsearch::Transport::Transport::Errors::BadRequest => exception
message = JSON.parse(exception.message[6..-1]).to_h.dig("error", "root_cause", 0, "reason")
Expand All @@ -131,7 +134,8 @@ def show
bmj = Benchmark.ms {
render json: WorkSerializer.new(@doi, options).serialized_json, status: :ok
}
logger.warn "[Benchmark] render " + bmj.to_s + " ms"
logger = Logger.new(STDOUT)
logger.warn "[Benchmark] render single" + bmj.to_s + " ms"
end

protected
Expand All @@ -143,7 +147,8 @@ def set_doi
response = Doi.find_by_id(params[:id], options)
@doi = response.results.first
}
logger.warn "[Benchmark] render " + bmd.to_s + " ms"
logger = Logger.new(STDOUT)
logger.warn "[Benchmark] request single " + bmd.to_s + " ms"

fail ActiveRecord::RecordNotFound unless @doi.present?
end
Expand Down

0 comments on commit 2012e81

Please sign in to comment.