Class: Arachni::UI::Web::Log

Inherits:
Object
  • Object
show all
Defined in:
lib/ui/web/log.rb

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

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

Instance Method Details

#entryObject



51
52
53
# File 'lib/ui/web/log.rb', line 51

def entry
    Entry
end