Skip to content

Commit 62542a1

Browse files
author
Francesc Campoy
committed
cosmetic changes
Change-Id: I6515f5dbc5ed3c19231bb8f4de820337984060d9
1 parent 7df8509 commit 62542a1

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

logpipe.go

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,15 @@ import (
2828
)
2929

3030
func main() {
31-
ctx := context.Background()
32-
3331
var opts struct {
3432
ProjectID string `short:"p" long:"project" description:"Google Cloud Platform Project ID" required:"true"`
3533
LogName string `short:"l" long:"logname" description:"The name of the log to write to" default:"default"`
3634
}
37-
3835
_, err := flags.Parse(&opts)
3936
if err != nil {
4037
os.Exit(2)
4138
}
4239

43-
projectID := &opts.ProjectID
44-
logName := &opts.LogName
45-
4640
// Check if Standard In is coming from a pipe
4741
fi, err := os.Stdin.Stat()
4842
if err != nil {
@@ -53,13 +47,14 @@ func main() {
5347
}
5448

5549
// Creates a client.
56-
client, err := logging.NewClient(ctx, *projectID)
50+
ctx := context.Background()
51+
client, err := logging.NewClient(ctx, opts.ProjectID)
5752
if err != nil {
5853
errorf("Failed to create client: %v", err)
5954
}
6055

6156
// Selects the log to write to.
62-
logger := client.Logger(*logName)
57+
logger := client.Logger(opts.LogName)
6358

6459
// Read from Stdin and log it to Stdout and Stackdriver
6560
s := bufio.NewScanner(os.Stdin)
@@ -74,7 +69,6 @@ func main() {
7469
if err := client.Close(); err != nil {
7570
errorf("Failed to close client: %v", err)
7671
}
77-
7872
if err := s.Err(); err != nil {
7973
errorf("Failed to scan input: %v", err)
8074
}

0 commit comments

Comments
 (0)