diff options
author | Christoph Helma <helma@in-silico.ch> | 2012-02-19 16:06:46 +0000 |
---|---|---|
committer | Christoph Helma <helma@in-silico.ch> | 2012-02-19 16:06:46 +0000 |
commit | 64135ae320998a836725786f95a4efd3b63f585c (patch) | |
tree | 6fdd74be366149c0bed0e6f42d6c3f47440bc916 | |
parent | 9fe1f6870cfd12c34eb4efef8f4e199e8324c1af (diff) |
logger.rb added
-rw-r--r-- | lib/logger.rb | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/lib/logger.rb b/lib/logger.rb new file mode 100644 index 0000000..c98f1ca --- /dev/null +++ b/lib/logger.rb @@ -0,0 +1,46 @@ +require 'logger' +class OTLogger < Logger + + def pwd + path = Dir.pwd.to_s + index = path.rindex(/\//) + return path if index==nil + path[(index+1)..-1] + end + + def trace() + lines = caller(0) + n = 2 + line = lines[n] + + while (line =~ /spork.rb/ or line =~ /create/ or line =~ /overwrite.rb/) + n += 1 + line = lines[n] + end + + index = line.rindex(/\/.*\.rb/) + return line if index==nil + line[index..-1] + end + + def format(msg) + pwd.ljust(18)+" :: "+msg.to_s+" :: "+trace + end + + def debug(msg) + super format(msg) + end + + def info(msg) + super format(msg) + end + + def warn(msg) + super format(msg) + end + + def error(msg) + super format(msg) + end + +end |