Almaz
Almaz is always watching!
Explanation
Almaz is rack middlware which logs request information to a redis server, under a preset user session variable.
Installation
gem install almaz
Example
Almaz::Capture
require 'almaz'
use Almaz::Capture
Almaz.redis_config = {:db => 0, :host => 'localhost', :port => 6379} # this is also the default
Almaz.session_variable = :user
By using Almaz::Capture and setting the session_variable to :user, all request are now logged under ‘almaz::user::(session[:user])’ in redis. Each user gets a separate list in the redis DB. All request that don’t have the session variable :user are logged under ‘almaz::user::’.
Almaz::View
require 'almaz'
use Almaz::View
Almaz::View.user('jpoz','password')
use Almaz::Capture
Almaz.session_variable = :user
Almaz::View is a separate middleware allows the information saved by Almaz::Capture into redis to be consumed via json. It has two routes:
- ‘/almaz’ a index of all the keys in the Redis DB
- ‘/almaz/:val’ the list of request information for the user who has the session variable value :val
Both are protected behind basic HTTP authentication. Which is setup by calling Almaz::View.user(‘username’,‘password’).