| OLD | NEW |
| 1 // Copyright 2016 The LUCI Authors. All rights reserved. | 1 // Copyright 2016 The LUCI Authors. All rights reserved. |
| 2 // Use of this source code is governed under the Apache License, Version 2.0 | 2 // Use of this source code is governed under the Apache License, Version 2.0 |
| 3 // that can be found in the LICENSE file. | 3 // that can be found in the LICENSE file. |
| 4 | 4 |
| 5 // eventlog is an example that demonstrates how to log to the eventlog service. | 5 // eventlog is an example that demonstrates how to log to the eventlog service. |
| 6 // It logs to a locally-run server. See go/localeventlog for more information. | 6 // It logs to a locally-run server. See go/localeventlog for more information. |
| 7 package main | 7 package main |
| 8 | 8 |
| 9 import ( | 9 import ( |
| 10 "fmt" | 10 "fmt" |
| 11 | 11 |
| 12 "golang.org/x/net/context" | 12 "golang.org/x/net/context" |
| 13 | 13 |
| 14 "github.com/luci/luci-go/common/eventlog" | 14 "github.com/luci/luci-go/common/eventlog" |
| 15 logpb "github.com/luci/luci-go/common/eventlog/proto" | 15 logpb "github.com/luci/luci-go/common/eventlog/proto" |
| 16 ) | 16 ) |
| 17 | 17 |
| 18 func main() { | 18 func main() { |
| 19 c := eventlog.NewClient("http://localhost:27910/log") | |
| 20 ctx := context.Background() | 19 ctx := context.Background() |
| 20 c := eventlog.NewClient(ctx, "http://localhost:27910/log") |
| 21 | 21 |
| 22 event := c.NewLogEvent(ctx, eventlog.Point()) | 22 event := c.NewLogEvent(ctx, eventlog.Point()) |
| 23 | 23 |
| 24 // Log a build event. Other kinds of events may also be logged. | 24 // Log a build event. Other kinds of events may also be logged. |
| 25 event.InfraEvent.BuildEvent = &logpb.BuildEvent{ /* TODO:fill in content
s */ } | 25 event.InfraEvent.BuildEvent = &logpb.BuildEvent{ /* TODO:fill in content
s */ } |
| 26 | 26 |
| 27 err := c.LogSync(ctx, event) | 27 err := c.LogSync(ctx, event) |
| 28 if err != nil { | 28 if err != nil { |
| 29 fmt.Printf("logging: %v\n", err) | 29 fmt.Printf("logging: %v\n", err) |
| 30 } | 30 } |
| 31 } | 31 } |
| OLD | NEW |