Class: Arachni::UI::Web::Log
Overview
A simple logger using DataMapper
@author: Tasos “Zapotek” Laskos
<[email protected]>
<[email protected]>
@version: 0.1.1
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.
44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/arachni/ui/web/log.rb', line 44 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
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/arachni/ui/web/log.rb', line 60 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 |