Class: Roby::Log::SQLiteLogger

Inherits:
Object
  • Object
show all
Defined in:
lib/roby/log/sqlite.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename) ⇒ SQLiteLogger

Returns a new instance of SQLiteLogger.



9
10
11
12
13
14
15
16
17
18
# File 'lib/roby/log/sqlite.rb', line 9

def initialize(filename)
    @db = SQLite3::Database.new(filename)
    db.execute("DROP TABLE IF EXISTS events")
    db.execute("CREATE TABLE events (
	       method TEXT,
	       sec    INTEGER,
	       usec   INTEGER,
	       args   BLOB)")
    @insert = db.prepare("insert into events values (?, ?, ?, ?)")
end

Instance Attribute Details

#dbObject (readonly)

Returns the value of attribute db.



8
9
10
# File 'lib/roby/log/sqlite.rb', line 8

def db
  @db
end

#insertObject (readonly)

Returns the value of attribute insert.



8
9
10
# File 'lib/roby/log/sqlite.rb', line 8

def insert
  @insert
end

Class Method Details

.replay(filename) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/roby/log/sqlite.rb', line 33

def self.replay(filename)
    db = SQLite3::Database.new(filename)
    method_name = nil
    db.execute("select * from events") do |method_name, sec, usec, args|
	time = Time.at(Integer(sec), Integer(usec))
	args = Marshal.load(StringIO.new(args))
	args.unshift time
	yield(method_name.to_sym, args)
    end
rescue
    STDERR.puts "ignoring call to #{method_name}: #{$!.full_message}"
end

Instance Method Details

#splat?Boolean

Returns:

  • (Boolean)


19
# File 'lib/roby/log/sqlite.rb', line 19

def splat?; false end