Skip to content

Commit 0766365

Browse files
committed
Disable IP Logging
1 parent 9c8dc79 commit 0766365

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
class ActiveSupport::BufferedLogger
2+
def formatter=(formatter)
3+
@log.formatter = formatter
4+
end
5+
end
6+
7+
class Formatter
8+
include ActiveSupport::TaggedLogging::Formatter
9+
SEVERITY_TO_COLOR_MAP = {'DEBUG'=>'0;37', 'INFO'=>'32', 'WARN'=>'33', 'ERROR'=>'31', 'FATAL'=>'31', 'UNKNOWN'=>'37'}
10+
11+
def call(severity, time, progname, msg)
12+
formatted_severity = sprintf("%-5s","#{severity}")
13+
formatted_time = time.strftime("%Y-%m-%d %H:%M:%S.") << time.usec.to_s[0..2].rjust(3)
14+
color = SEVERITY_TO_COLOR_MAP[severity]
15+
16+
"\033[0;37m#{formatted_time}\033[0m [\033[#{color}m#{formatted_severity}\033[0m] #{msg.strip} (pid:#{$$})\n".gsub(/Started(.*)for(.*)at/,'Started\1at')
17+
end
18+
19+
end
20+
21+
Rails.logger.formatter = Formatter.new

0 commit comments

Comments
 (0)