(tempFile *os.File, truncateForPingOutput bool)
| 330 | } |
| 331 | |
| 332 | func gatherOutput(tempFile *os.File, truncateForPingOutput bool) []byte { |
| 333 | var outputBytes []byte |
| 334 | const outputForPingMaxLen int64 = 1000 |
| 335 | const outputForLogUploadMaxLen int64 = 100000000 |
| 336 | if noStdoutPassthru || tempFile == nil { |
| 337 | outputBytes = []byte{} |
| 338 | } else { |
| 339 | |
| 340 | if size, err := getFileSize(tempFile); err == nil { |
| 341 | // In all cases, if we have to truncate, we want to read the END |
| 342 | // of the log file, because it is more informative. |
| 343 | if truncateForPingOutput && size > outputForPingMaxLen { |
| 344 | outputBytes = make([]byte, outputForPingMaxLen) |
| 345 | tempFile.Seek(outputForPingMaxLen*-1, 2) |
| 346 | } else if !truncateForPingOutput && size > outputForLogUploadMaxLen { |
| 347 | outputBytes = make([]byte, outputForLogUploadMaxLen) |
| 348 | tempFile.Seek(outputForLogUploadMaxLen*-1, 2) |
| 349 | } else { |
| 350 | outputBytes = make([]byte, size) |
| 351 | tempFile.Seek(0, 0) |
| 352 | } |
| 353 | tempFile.Read(outputBytes) |
| 354 | } |
| 355 | } |
| 356 | |
| 357 | return outputBytes |
| 358 | } |
| 359 | |
| 360 | func isStaleFile(file os.FileInfo) bool { |
| 361 | var timeLimit = 3 * 24 * time.Hour |
no test coverage detected