Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save gary/0c3c8cbfdc5bfb88455251817e2f8261 to your computer and use it in GitHub Desktop.
Save gary/0c3c8cbfdc5bfb88455251817e2f8261 to your computer and use it in GitHub Desktop.
Make platform logging less noisy
From 4474caab21f80a2c5e0ba6af3dd1465a19ce1378 Mon Sep 17 00:00:00 2001
From: Gary Iams <giams@di.fm>
Date: Thu, 16 Jun 2016 19:27:25 -0400
Subject: [PATCH] Quick 'n dirty solution for reducing logging noise
- Disable NewRelic. Reporting issues instrumenting the AssetsController.
- Fix how VipsProcessor constant is referenced in the AssetsController
- Ignore the response code from Image#destroy_file!'s WebDAV request
---
api/app/controllers/assets_controller.rb | 8 ++++----
api/config/newrelic.yml | 2 +-
app/models/image.rb | 3 ++-
3 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/api/app/controllers/assets_controller.rb b/api/app/controllers/assets_controller.rb
index 17a6025..5882384 100644
--- a/api/app/controllers/assets_controller.rb
+++ b/api/app/controllers/assets_controller.rb
@@ -80,12 +80,12 @@ class AssetsController < ApplicationController
if image.width != width || image.height != height || wants_type != image.mime_type || quality != 0
begin
- processor = VipsProcessor.new_from_blob(image_data, image.mime_type, wants_type, quality)
+ processor = ::VipsProcessor.new_from_blob(image_data, image.mime_type, wants_type, quality)
rescue Image::FormatError, VIPS::Error
image = ImageUtils.encode_image_as_png(image)
image_data = image.fetch_from_persistent_storage
wants_type = 'image/png'
- processor = VipsProcessor.new_from_blob(image_data, image.mime_type, wants_type, quality)
+ processor = ::VipsProcessor.new_from_blob(image_data, image.mime_type, wants_type, quality)
end
if image.width != width || image.height != height
@@ -105,7 +105,7 @@ class AssetsController < ApplicationController
image = ImageUtils.encode_image_as_png(image)
image_data = image.fetch_from_persistent_storage
wants_type = 'image/png'
- image_data = prepare_resize(VipsProcessor.new_from_blob(image_data, image.mime_type, wants_type, quality), width, height).output
+ image_data = prepare_resize(::VipsProcessor.new_from_blob(image_data, image.mime_type, wants_type, quality), width, height).output
end
else
Rails.logger.info 'Image perfect match, not transforming'
@@ -148,7 +148,7 @@ class AssetsController < ApplicationController
begin
image_data = image.fetch_from_persistent_storage
- processor = VipsProcessor.new_from_blob(image_data, image.mime_type, wants_type, quality)
+ processor = ::VipsProcessor.new_from_blob(image_data, image.mime_type, wants_type, quality)
processor.resize_center_cropped(width, height)
images << {id: channel.id, data: processor.output}
rescue StandardError => e
diff --git a/api/config/newrelic.yml b/api/config/newrelic.yml
index 2008377..93a4457 100644
--- a/api/config/newrelic.yml
+++ b/api/config/newrelic.yml
@@ -23,7 +23,7 @@ common: &default_settings
development:
<<: *default_settings
monitor_mode: false
- developer_mode: true
+ developer_mode: false
test:
<<: *default_settings
diff --git a/app/models/image.rb b/app/models/image.rb
index dfae31b..bf58743 100644
--- a/app/models/image.rb
+++ b/app/models/image.rb
@@ -212,8 +212,9 @@ class Image < ActiveRecord::Base
request.basic_auth(AssetsWebdavConfig[:username], AssetsWebdavConfig[:password])
response = http.request(request)
- response.value unless response.code == '404'
+ # FIXME: response.value unless response.code == '404'
end
+ # rescue Net::HTTPExceptions
end
def destroy_on_local_filesystem!
--
1.9.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment