diff options
author | Martin Gütlein <martin.guetlein@gmail.com> | 2010-02-23 17:19:01 +0100 |
---|---|---|
committer | Martin Gütlein <martin.guetlein@gmail.com> | 2010-02-23 17:19:01 +0100 |
commit | 1a2116574c356241a55fb0bb7d922a042ffd4465 (patch) | |
tree | d889af696d98a6f9cb127a3e2bb73cd4d4fd5a0c /lib | |
parent | ceb2d32650ee20c1874cbd9e880f88b3ac175eb2 (diff) |
format logging once again
Diffstat (limited to 'lib')
-rw-r--r-- | lib/environment.rb | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/lib/environment.rb b/lib/environment.rb index 3329089..c4de0b5 100644 --- a/lib/environment.rb +++ b/lib/environment.rb @@ -41,6 +41,12 @@ end # logging class MyLogger < 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) @@ -59,26 +65,30 @@ class MyLogger < Logger # puts "-" index = line.rindex(/\/.*\.rb/) # raise "index = nil" if index==nil - return line if index==nil || index<4 + return line if index==nil # puts "<<< "+line[index..-1].size.to_s+" <<< "+line[index..-1] # raise "stop" - ".."+line[(index-3)..-1] + line[index..-1] + end + + def format(msg) + pwd.ljust(18)+" :: "+msg.to_s+" :: "+trace end - def debug(param) - super trace.ljust(50)+" :: "+param.to_s + def debug(msg) + super format(msg) end - def info(param) - super trace.ljust(50)+" :: "+param.to_s + def info(msg) + super format(msg) end - def warn(param) - super trace.ljust(50)+" :: "+param.to_s + def warn(msg) + super format(msg) end - def error(param) - super trace.ljust(50)+" :: "+param.to_s + def error(msg) + super format(msg) end end @@ -87,6 +97,7 @@ logfile = "#{LOG_DIR}/#{ENV["RACK_ENV"]}.log" LOGGER = MyLogger.new(logfile,'daily') # daily rotation #LOGGER = MyLogger.new(STDOUT) + LOGGER.level = Logger::DEBUG # RDF namespaces |