@@ -90,8 +90,8 @@ func (d *DefaultEncoder) composeMsgInto(
9090 }
9191
9292 if isDateOrTimeEnabled {
93- dateStr , timeStr , dateTimeStr := d .DateTimePrinter .RetrieveDateTime (dateEnabled , timeEnabled )
94- d .addFormattedDateTime (buf , dateStr , timeStr , dateTimeStr )
93+ dateStr , timeStr , _ := d .DateTimePrinter .RetrieveDateTime (dateEnabled , timeEnabled )
94+ d .addFormattedDateTime (buf , dateStr , timeStr )
9595 }
9696
9797 if showLogLevel || isDateOrTimeEnabled {
@@ -106,25 +106,20 @@ func (d *DefaultEncoder) composeMsgInto(
106106// addFormattedDateTime correctly formats the dateTime string, adding and removing square brackets
107107// and white spaces as needed.
108108// While formatting, it adds the dateTime string to the given buffer.
109- func (d * DefaultEncoder ) addFormattedDateTime (buf * bytes.Buffer , dateStr , timeStr , dateTimeStr string ) {
110- if dateStr == "" && timeStr == "" && dateTimeStr == "" {
109+ func (d * DefaultEncoder ) addFormattedDateTime (buf * bytes.Buffer , dateStr , timeStr string ) {
110+ if dateStr == "" && timeStr == "" {
111111 return
112112 }
113113
114114 buf .WriteByte ('[' )
115+ buf .WriteString (dateStr )
115116
116- if dateTimeStr != "" {
117- buf .WriteString (dateTimeStr )
118- } else {
119- buf .WriteString (dateStr )
120-
121- if dateStr != "" && timeStr != "" {
122- buf .WriteByte (' ' )
123- }
124-
125- buf .WriteString (timeStr )
117+ if dateStr != "" && timeStr != "" {
118+ buf .WriteByte (' ' )
126119 }
127120
121+ buf .WriteString (timeStr )
122+
128123 buf .WriteByte (']' )
129124}
130125
0 commit comments