summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBaron Bloomer <baronbloomer@gmail.com>2021-07-29 09:31:33 +0100
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2021-12-18 08:38:57 +0900
commita8b11b5cdd5fedd30a65e60bdae4c00d259d4191 (patch)
treec98208d108f1e4bd4791d2b5cbc0ee9691bf29d6
parentcc5fcae1705f8c4f6dc02d76bbd7940ba9666d59 (diff)
[ruby/logger] Changes to datetime formatting
Formatting a datetime should only pertain to itself and valid datetimes do not contain a space. Should there be a desire to show show a space between the datetime and the process pid in the formatted log, this formatting logic should take place there. Furthermore, the default datetime format is moved to a class variable to allowing this variable to be overwritten by subclasses. https://github.com/ruby/logger/commit/7cbd434349
-rw-r--r--lib/logger/formatter.rb5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/logger/formatter.rb b/lib/logger/formatter.rb
index 6a135b6fab..62bff7097a 100644
--- a/lib/logger/formatter.rb
+++ b/lib/logger/formatter.rb
@@ -3,7 +3,8 @@
class Logger
# Default formatter for log messages.
class Formatter
- Format = "%s, [%s#%d] %5s -- %s: %s\n"
+ Format = "%s, [%s #%d] %5s -- %s: %s\n"
+ DatetimeFormat = "%Y-%m-%dT%H:%M:%S.%6N"
attr_accessor :datetime_format
@@ -19,7 +20,7 @@ class Logger
private
def format_datetime(time)
- time.strftime(@datetime_format || "%Y-%m-%dT%H:%M:%S.%6N ")
+ time.strftime(@datetime_format || DatetimeFormat)
end
def msg2str(msg)