Skip to content

Commit

Permalink
next try
Browse files Browse the repository at this point in the history
  • Loading branch information
karoltravis committed Feb 2, 2022
1 parent c8b85d7 commit 6a09122
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions lib/travis/api/app/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,33 @@ def censor(message)
end
end

module Sinatra
module QuietLogger

@extensions = %w(png gif jpg jpeg woff tff svg eot css js coffee scss)

class << self
attr_accessor :extensions

def registered(app)
::Rack::CommonLogger.class_eval <<-PATCH
alias call_and_log call
def call(env)
ext = env['REQUEST_PATH'].split('.').last
if #{extensions.inspect}.include? ext
@app.call(env)
else
call_and_log(env)
end
end
PATCH
end
end

end
end


class Travis::Api::App
# Superclass for any endpoint and middleware.
Expand Down Expand Up @@ -74,9 +101,8 @@ def call(env)
else
disable :logging, :dump_errors
end
register QuietLogger

logger = CensoredLogger.new(File.open('/var/log/travis.log', 'a'))
set :logger, logger
register :subclass_tracker, :expose_pattern
helpers :respond_with, :mime_types
end
Expand Down

0 comments on commit 6a09122

Please sign in to comment.