log_buddy and Windows

I recently started playing around with the log_buddy gem for Rails and because my development machine is on windows, the “d” method wasn’t playing nice with some paths.  it didn’t like paths that included the drive letter.

this is a sample of a line that would cause log_buddy to barf.  it just so happens to also be the line that causes the error.  🙂

c:/ruby/lib/ruby/gems/1.8/gems/log_buddy-0.0.5/lib/log_buddy.rb:98:in `read_line'

the original line looked like this…

file, line_number = frame.split(/:/, 2)

the fix is to replace that line with

file, line_number = frame.reverse.split(/:/, 3)[1..2].map(&:reverse).reverse

yeah.  ugly, and maybe could be written better but it works for me.

now if only I could get log_buddy to output good inspections of objects I toss to it… like “current_user”.  I’m prolly using it wrong right now, but this isn’t helpful…

current_user = '#<User:0x47143d8>'

just saying.  🙂

UPDATE: I monkeypatched log_buddy to fix this functionality. I created a “RAILS_ROOT/lib/log_buddy_extensions.rb” file with the following code.

class LogBuddy

  private

  # Return the calling line
  def self.read_line(frame)
    file, line_number = frame.reverse.split(/:/, 3)[1..2].map(&:reverse).reverse
    line_number = line_number.to_i
    lines = File.readlines(file)
    lines[line_number - 1]
  end

end

and I figured out that the “current_user” line above shouldn’t be …

d { current_user }

it should be

d { current_user.inspect }

that outputs what I want …

current_user.inspect = '#<User id: 1, login: "matte", email: "matte@localhost", crypted_password: "...", salt: "...", created_at: "2007-08-30 18:23:32", updated_at: "2008-07-08 18:57:45", remember_token: "...", remember_token_expires_at: "2008-07-22 18:57:45", name: "...", password_reset_code: nil, company_id: 2, active: true>'

2 Comments

  1. as usual, that all sounded like “blah, blah, blah, blah.” oops, just sneezed while chewing on some pringles. made for an interesting choke.

  2. 10 PRINT “HELLO”
    20 GOTO 10

    RUN

    HELLOHELLOHELLOHELLOHELLOHELLOHELLOHELLOHE
    LLOHELLOHELLOHELLOHELLOHELLOHELLOHELLOHELL
    OHELLOHELLOHELLOHELLOHELLOHELLOHELLOHELLO
    HELLOHELLOHELLOHELLOHELLOHELLOHELLOHELLOHE
    LLOHELLOHELLOHELLOHELLOHELLOHELLOHELLOHELL
    OHELLOHELLOHELLOHELLOHELLOHELLOHELLOHELLOH
    ELLOHELLOHELLOHELLOHELLOHELLOHELLOHELLOHELL
    OHELLO ….

    😉

Comments are closed.