(payload []byte, source *logging.FileBodySource)
| 633 | } |
| 634 | |
| 635 | func mergeFileBodySource(payload []byte, source *logging.FileBodySource) ([]byte, error) { |
| 636 | if source == nil { |
| 637 | return payload, nil |
| 638 | } |
| 639 | defer cleanupFileBodySources(source) |
| 640 | if !source.HasPayload() { |
| 641 | return payload, nil |
| 642 | } |
| 643 | var buf bytes.Buffer |
| 644 | if len(payload) > 0 { |
| 645 | buf.Write(payload) |
| 646 | if !bytes.HasSuffix(payload, []byte("\n")) { |
| 647 | buf.WriteByte('\n') |
| 648 | } |
| 649 | buf.WriteByte('\n') |
| 650 | } |
| 651 | if errWrite := source.WriteTo(&buf); errWrite != nil { |
| 652 | return nil, errWrite |
| 653 | } |
| 654 | return buf.Bytes(), nil |
| 655 | } |
| 656 | |
| 657 | func cleanupFileBodySources(sources ...*logging.FileBodySource) { |
| 658 | for _, source := range sources { |
no test coverage detected