Skip to content

Commit 7198858

Browse files
author
Francesc Campoy
committed
use tee reader
Change-Id: Ia03c144f667bcdc2d28d781a5fae8e656da8d997
1 parent 62542a1 commit 7198858

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

logpipe.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package main
1919
import (
2020
"bufio"
2121
"fmt"
22+
"io"
2223
"os"
2324

2425
flags "github.com/jessevdk/go-flags"
@@ -57,11 +58,9 @@ func main() {
5758
logger := client.Logger(opts.LogName)
5859

5960
// Read from Stdin and log it to Stdout and Stackdriver
60-
s := bufio.NewScanner(os.Stdin)
61+
s := bufio.NewScanner(io.TeeReader(os.Stdin, os.Stdout))
6162
for s.Scan() {
62-
text := s.Text()
63-
fmt.Println(text)
64-
logger.Log(logging.Entry{Payload: text})
63+
logger.Log(logging.Entry{Payload: s.Text()})
6564
}
6665

6766
// Closes the client and flushes the buffer to the Stackdriver Logging

0 commit comments

Comments
 (0)