Module: LogBuddy::Mixin

The main Mixin that gets added on the init call

Public Instance Methods


d (msg = nil, &blk)

This is where the magic happens. This method can take a plain old string, and it will log it like any call to Logger#debug. To get the name of the thing you are logging and its value, use the block form:

   d { @a }

Seperate with semicolons for multiple things - pretty much any valid ruby will work.

   d { @@foo; MY_CONST }
   d { @person; @@place; object.method() }
    # File lib/log_buddy.rb, line 46
46:     def d(msg = nil, &blk)
47:       LogBuddy.debug(msg) if msg
48:       return unless block_given?
49:       begin
50:         logged_line = LogBuddy.read_line(caller[0])
51:         arguments = LogBuddy.parse_args(logged_line)
52:         arguments.each do |arg|
53:           result = eval(arg, blk.binding)
54:           LogBuddy.debug(%[#{arg} = '#{result}'\n])
55:         end
56:       rescue Exception => e
57:         LogBuddy.debug "LogBuddy caught an exception: #{e.message}"
58:       end
59:     end

logger ()

Add a default logger to everything, everywhere.

    # File lib/log_buddy.rb, line 62
62:     def logger
63:       LogBuddy.default_logger
64:     end