Class: Arachni::UI::Web::Log
Overview
A simple logger using DataMapper
Defined Under Namespace
Classes: Entry
Instance Method Summary collapse
- #entry ⇒ Object
-
#initialize(opts, settings) ⇒ Log
constructor
A new instance of Log.
- #method_missing(sym, *args, &block) ⇒ Object
Constructor Details
#initialize(opts, settings) ⇒ Log
Returns a new instance of Log.
48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/arachni/ui/web/log.rb', line 48 def initialize( opts, settings ) @opts = opts @settings = settings DataMapper::setup( :log, "sqlite3://#{@settings.db}/log.db" ) DataMapper.repository( :log ) { DataMapper.finalize Entry.auto_upgrade! } end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, &block) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/arachni/ui/web/log.rb', line 64 def method_missing( sym, *args, &block ) owner, action = sym.to_s.split( '_', 2 ) if args && args[1] object = args[1] end if env = args[0] addr = env['REMOTE_ADDR'] host = env['REMOTE_HOST'] end DataMapper.repository( :log ) { Entry.create( :action => action, :owner => owner, :object => object, :client_addr => addr, :client_host => host, :datestamp => Time.now.asctime ) } end |