17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/easy_logger/logging_example.rb', line 17
def format_message(severity, timestamp, progname, msg)
i = 2
methode = caller[i].split('`')[1].split("'")[0]
each_true = false
puts methode if methode == "each"
each_true = true if methode == ""
while methode == "debug" || methode == "info" || methode == "error" || methode.split(' ')[0] == "each"
i += 1
methode = caller[i].split('`')[1].split("'")[0]
puts methode if each_true
end
methode = methode.split(' ')[0] == "block" ? methode.split(' ')[-1].center(17) : methode.center(17)
objecte = caller[i].split(':')[0].split('/')[-1].split('.')[0].camelize.center(16)
"#{timestamp.strftime("%d %b %H:%M:%S")}|rails[#{$PID}]|#{severity.center(8)}|#{objecte}|#{methode}| #{msg2str(msg).gsub(/\n/, '').lstrip}\n"
end
|