lib/rgot/common.rb in rgot-0.1.2 vs lib/rgot/common.rb in rgot-0.1.3
- old
+ new
@@ -37,24 +37,28 @@
@mutex.synchronize { @finished = true }
end
def log(*args)
internal_log(args.map(&:to_s).join(' '))
+ nil
end
def logf(*args)
internal_log(sprintf(*args))
+ nil
end
def error(*args)
internal_log(args.map(&:to_s).join(' '))
fail!
+ nil
end
def errorf(*args)
internal_log(sprintf(*args))
fail!
+ nil
end
def fatal(*args)
internal_log(args.map(&:to_s).join(' '))
fail_now
@@ -88,10 +92,11 @@
end
private
def decorate(str)
- c = caller[2] # internal_log -> other log -> running method
+ # internal_log -> synchronize -> internal_log -> other log -> running method
+ c = caller[4]
path = c.sub(/:.*/, '')
line = c.match(/:(\d+?):/)[1]
relative_path = Pathname.new(path).relative_path_from(Pathname.new(Dir.pwd)).to_s
"\t#{relative_path}:#{line}: #{str}\n"
end