(sink logSink, r io.Reader, done chan<- any, level proto.LogLevel)
| 608 | } |
| 609 | |
| 610 | func readAndLog(sink logSink, r io.Reader, done chan<- any, level proto.LogLevel) { |
| 611 | defer close(done) |
| 612 | scanner := bufio.NewScanner(r) |
| 613 | for scanner.Scan() { |
| 614 | var log terraformProvisionLog |
| 615 | err := json.Unmarshal(scanner.Bytes(), &log) |
| 616 | if err != nil { |
| 617 | if strings.TrimSpace(scanner.Text()) == "" { |
| 618 | continue |
| 619 | } |
| 620 | |
| 621 | sink.ProvisionLog(level, scanner.Text()) |
| 622 | continue |
| 623 | } |
| 624 | |
| 625 | logLevel := convertTerraformLogLevel(log.Level, sink) |
| 626 | if logLevel == proto.LogLevel_TRACE { |
| 627 | // Skip TRACE log entries as they produce a lot of noise. |
| 628 | // |
| 629 | // FIXME consider config.ProvisionerLogLevel to enable custom level logging |
| 630 | // instead of "just-debug-level" mode. |
| 631 | continue |
| 632 | } |
| 633 | |
| 634 | // Degrade JSON log entries marked as INFO as these are logs produced in debug mode. |
| 635 | if logLevel == proto.LogLevel_INFO { |
| 636 | logLevel = proto.LogLevel_DEBUG |
| 637 | } |
| 638 | sink.ProvisionLog(logLevel, log.Message) |
| 639 | } |
| 640 | } |
| 641 | |
| 642 | // provisionLogWriter creates a WriteCloser that will log each JSON formatted terraform log. The WriteCloser must be |
| 643 | // closed by the caller to end logging, after which the returned channel will be closed to indicate that logging of the |
no test coverage detected