File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change 1- // Copyright 2019 Hewlett Packard Enterprise Development LP
1+ // Copyright 2020 Hewlett Packard Enterprise Development LP
22
33package logger
44
@@ -332,6 +332,17 @@ func (hook *FileHook) Fire(entry *log.Entry) error {
332332 return err
333333 }
334334
335+ // For Windows only, insert '/r' in front of any tailing '/n'. Windows text files end
336+ // lines with CRLF while other platforms just end with LF.
337+ if runtime .GOOS == "windows" {
338+ for i := len (lineBytes ) - 1 ; i > 0 ; i -- {
339+ if (lineBytes [i ] != '\n' ) || (i > 0 && lineBytes [i - 1 ] == '\r' ) {
340+ break
341+ }
342+ lineBytes = append (lineBytes [:i ], append ([]byte {'\r' }, lineBytes [i :]... )... )
343+ }
344+ }
345+
335346 hook .logWriter .Write (lineBytes )
336347 return nil
337348}
You can’t perform that action at this time.
0 commit comments