diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 664212e..3e1bf49 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,11 +14,11 @@ jobs: - name: Checkout uses: actions/checkout@v3 - name: Set up Go - uses: actions/setup-go@v3 + uses: actions/setup-go@v4 with: - go-version: 1.19 + go-version: "1.20" - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v3 + uses: goreleaser/goreleaser-action@v4 with: version: latest args: release --rm-dist diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5a2d5c6..7991c5d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -5,13 +5,13 @@ jobs: strategy: matrix: go: - - 1.18.5 - - 1.19 + - "1.19" + - "1.20" name: Build runs-on: ubuntu-latest steps: - name: Set up Go - uses: actions/setup-go@v3 + uses: actions/setup-go@v4 with: go-version: ${{ matrix.go }} id: go diff --git a/tracer.go b/tracer.go index abff49e..6d5fca0 100644 --- a/tracer.go +++ b/tracer.go @@ -35,6 +35,7 @@ type Tracer struct { sns *sns.Client timeline *Timeline buf *bytes.Buffer + w io.Writer now time.Time headBegin time.Time @@ -113,6 +114,7 @@ func NewWithConfig(config aws.Config) (*Tracer, error) { seen: make(map[string]bool), }, buf: new(bytes.Buffer), + w: os.Stdout, }, nil } @@ -130,6 +132,10 @@ type RunOption struct { Duration time.Duration } +func (t *Tracer) SetOutput(w io.Writer) { + t.w = w +} + func (t *Tracer) Run(ctx context.Context, cluster string, taskID string, opt *RunOption) error { t.now = time.Now() t.option = opt @@ -158,8 +164,8 @@ func (t *Tracer) Run(ctx context.Context, cluster string, taskID string, opt *Ru func (t *Tracer) report(ctx context.Context, cluster, taskID string) { opt := t.option if opt.Stdout { - fmt.Fprintln(os.Stdout, subject(cluster, taskID)) - if _, err := t.WriteTo(os.Stdout); err != nil { + fmt.Fprintln(t.w, subject(cluster, taskID)) + if _, err := t.WriteTo(t.w); err != nil { fmt.Fprintln(os.Stderr, err) } }