我想实现一个类似这样的日志函数:
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
函数的正确实现。
__LINE__
(而不是__LINENO__
)。 - Eric B