зеркало из https://github.com/github/ruby.git
[ruby/logger] Another performance improvement on the Formatter by
using Kernel#sprintf over String#% (https://github.com/ruby/logger/pull/75) * Prefer Kernel#sprintf over String#% for formatting Strings
This commit is contained in:
Родитель
7ab4820af7
Коммит
7e121dc4a8
|
@ -3,7 +3,7 @@
|
|||
class Logger
|
||||
# Default formatter for log messages.
|
||||
class Formatter
|
||||
Format = "%s, [%s #%d] %5s -- %s: %s\n"
|
||||
Format = "%.1s, [%s #%d] %5s -- %s: %s\n"
|
||||
DatetimeFormat = "%Y-%m-%dT%H:%M:%S.%6N"
|
||||
|
||||
attr_accessor :datetime_format
|
||||
|
@ -13,8 +13,7 @@ class Logger
|
|||
end
|
||||
|
||||
def call(severity, time, progname, msg)
|
||||
Format % [severity[0, 1], format_datetime(time), Process.pid, severity, progname,
|
||||
msg2str(msg)]
|
||||
sprintf(Format, severity, format_datetime(time), Process.pid, severity, progname, msg2str(msg))
|
||||
end
|
||||
|
||||
private
|
||||
|
|
Загрузка…
Ссылка в новой задаче