Class: Roby::Log::SQLiteLogger
Instance Attribute Summary collapse
-
#db ⇒ Object
readonly
Returns the value of attribute db.
-
#insert ⇒ Object
readonly
Returns the value of attribute insert.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(filename) ⇒ SQLiteLogger
constructor
A new instance of SQLiteLogger.
- #splat? ⇒ Boolean
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
#db ⇒ Object (readonly)
Returns the value of attribute db.
8 9 10 |
# File 'lib/roby/log/sqlite.rb', line 8 def db @db end |
#insert ⇒ Object (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}: #{$!.}" end |
Instance Method Details
#splat? ⇒ Boolean
19 |
# File 'lib/roby/log/sqlite.rb', line 19 def splat?; false end |