Last active
December 24, 2015 09:09
-
-
Save kkosuge/6774844 to your computer and use it in GitHub Desktop.
Rails.logger に 時間/PID/LEVEL 追記するやつ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
config.logger = Logger.new(config.paths["log"].first) | |
config.logger.formatter = Logger::Formatter.new |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Logger | |
class Formatter | |
def call(severity, time, progname, msg) | |
format = "[%s][%d][%s] %s\n" | |
messages = msg2str(msg) | |
[].tap do |array| | |
messages.each_line do |message| | |
array << (format % ["#{time.strftime('%Y-%m-%d %H:%M:%S')}.#{'%06d' % time.usec.to_s}", $$, severity, message.chomp]) | |
end | |
end.join | |
end | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[2013-10-02 13:07:04.812954][76244][INFO] Started GET "/" for 127.0.0.1 at 2013-10-02 13:07:04 +0900 | |
[2013-10-02 13:07:04.880362][76244][INFO] Processing by RootController#index as HTML | |
[2013-10-02 13:07:04.957657][76244][DEBUG] User Load (0.2ms) SELECT `users`.* FROM `users` ORDER BY id desc LIMIT 25 | |
[2013-10-02 13:07:05.013784][76244][INFO] Rendered root/index.html.erb within layouts/application (31.2ms) | |
[2013-10-02 13:07:05.193171][76244][INFO] Rendered shared/_footer.html.erb (0.5ms) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment