Module
MyDebug
Home
In: locana/debug.rb

This module provides methods for quickly printing messages to the display at run-time when the -d option is used.

Methods

debug, dfh, set_debug_level,
Public Instance methods
dfh(*args) src

dfh is short for Debug Function Header. It returns a string combining the following:

For example:

 def name()  # this object has a name method
    return 'MyName'
 end
 def MyClass.method_name(param1, param2)
    debug 2, dfh(param1, param2) =>  MyClass'MyName'.method_name(param1, param2)
 end

This can be used to start each debug and raise to keep the messages consistent and easier to manage. I use this to add the things I like to see in debug statements.

set_debug_level(debug_level) src

Set the level of debug (sets @@debug_level). The higher the number, the more debug. Debug_level is a number relating to the debug_level of each debug.

debug(debug_level, *values) src

This works exactly like a print statement with the following exceptions:

This example prints when $DEBUG is true and @@debug_level is >= 5:

   debug 5, 'test ', 2400, ' message'  if ($DEBUG)
   =>  <<05|test 2400 message>>

This example prints when $DEBUG is true and @@debug_level is >= 6, assume this is called inside instance method ‘save()’ of class Locana and the object has a name of test_object:

 def name()
    'test_object'
 end
 def save(param1, param2)    # where param1 == 2400 and param2 == "message"
   debug 6, dfh(param1, param2) if ($DEBUG)
   =>  <<06|Locana'test_object'.save(2400, "message")>>
 end

This example prints when $DEBUG is true and @@debug_level is >= 10, assume this is called inside class method "save(2400, ‘p2’)" of class Locana:

   debug 10, dfh(param.inspect, param2.inpect), " - what ever you want to reveal goes here" if ($DEBUG)
    =>  <<10|Locana.save(2400, "p2") - what ever you want to reveal goes here>>

Seva Software


Thank you for taking the time to visit this web page. I trust you found the information contained in this page useful.
Please email any questions, concerns, or issues with this web site to webmaster@sevasoftware.com.
Please remember Seva Software when your company would benefit from an experienced database architect and software engineer.

http://www.arunadb.org http://www.locana.org http://www.ruby-lang.org http://www.coolwell.org http://www.sevasoftware.com