Class: Arachni::UI::Web::Log
Overview
A simple logger using DataMapper
@author: Tasos “Zapotek” Laskos
<[email protected]>
<[email protected]>
@version: 0.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.
40 41 42 43 44 45 46 47 48 49 |
# File 'lib/ui/web/log.rb', line 40 def initialize( opts, settings ) @opts = opts @settings = settings DataMapper::setup( :default, "sqlite3://#{@settings.db}/log.db" ) 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
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/ui/web/log.rb', line 55 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 Entry.create( :action => action, :owner => owner, :object => object, :client_addr => addr, :client_host => host, :datestamp => Time.now ) end |