blob: df38d77c26a006d7c7f832a796574a18d27f248a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
require 'logger'
# 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)
n = 2
line = lines[n]
while (line =~ /spork.rb/ or line =~ /as_task/ or line =~ /ot-logger.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+" :: "+($sinatra ? $sinatra.request.env['REMOTE_ADDR'] : nil).to_s
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
|