我想实现这样的日志功能:
def mylog(str)
puts __FILE__, ":"__LINENO__, ":", str # Here how to get __FILE__ and __LINENO__ is my question.
end
当我打电话时mylog
:
mylog 'hello' # say I call this in my.rb line 10
我期望输出:
my.rb:10:hello
请帮助正确实现mylog
功能。