No release in over 3 years
Low commit activity in last 3 years
Library for usage logging
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.17
~> 2.2
~> 13.0.3
~> 3.10
 Project Readme

resurfaceio-logger-ruby

Easily log API requests and responses to your own security data lake.

gem CodeFactor License Contributing

Contents

  • Dependencies
  • Installing With Bundler
  • Logging From Rails Controller
  • Logging From Rack Middleware
  • Logging From Sinatra
  • Logging With API
  • Protecting User Privacy

Requires Ruby 2.x. No other dependencies to conflict with your app.

Add this line to your Gemfile:

gem 'resurfaceio-logger'

Then install with Bundler: bundle install

After installing the gem, add an around_action to your Rails controller.

require 'resurfaceio/all'

class MyController < ApplicationController
  
  around_action HttpLoggerForRails.new(
    url: 'http://localhost:7701/message', 
    rules: 'include debug'
  )

end

After installing the gem, add these lines below to config.ru, before the final 'run' statement.

require 'resurfaceio/all'

use HttpLoggerForRack,
  url: 'http://localhost:7701/message',
  rules: 'include debug'

run <...>

After installing the gem, create a logger and call it from the routes of interest.

require 'sinatra'
require 'resurfaceio/all'

logger = HttpLogger.new(
  url: 'http://localhost:7701/message', 
  rules: 'include debug'
)

get '/' do
  response_body = '<html>Hello World</html>'
  HttpMessage.send(logger, request, response, response_body)
  response_body
end

post '/' do
  status 401
  HttpMessage.send(logger, request, response)
  ''
end

Loggers can be directly integrated into your application using our API. This requires the most effort compared with the options described above, but also offers the greatest flexibility and control.

API documentation

Loggers always have an active set of rules that control what data is logged and how sensitive data is masked. All of the examples above apply a predefined set of rules (include debug), but logging rules are easily customized to meet the needs of any application.

Logging rules documentation


© 2016-2024 Graylog, Inc.