Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(254)

Unified Diff: examples/eventlog/main.go

Issue 2517503002: luci-go: Basic support for event logging in Go. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« common/eventlog/settings.go ('K') | « common/eventlog/settings.go ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: examples/eventlog/main.go
diff --git a/examples/eventlog/main.go b/examples/eventlog/main.go
new file mode 100644
index 0000000000000000000000000000000000000000..213dc2530e855b1b38ec7286323fa4ba5c3b9cd1
--- /dev/null
+++ b/examples/eventlog/main.go
@@ -0,0 +1,32 @@
+// Copyright 2016 The LUCI Authors. All rights reserved.
+// Use of this source code is governed under the Apache License, Version 2.0
+// that can be found in the LICENSE file.
+
+// eventlog is an example that demonstrates how to log to the eventlog service.
+// It logs to a locally-run server. See go/localeventlog for more information.
+package main
+
+import (
+ "fmt"
+ "time"
+
+ "golang.org/x/net/context"
+
+ "github.com/luci/luci-go/common/eventlog"
+ logpb "github.com/luci/luci-go/common/eventlog/proto"
+)
+
+func main() {
+ c := eventlog.NewClient("http://localhost:27910/log")
+ ctx := context.Background()
+
+ event := c.NewLogEvent(ctx, eventlog.TypedTime{time.Now(), logpb.ChromeInfraEvent_POINT})
+
+ // Log a build event. Other kinds of events may also be logged.
+ event.InfraEvent.BuildEvent = &logpb.BuildEvent{ /* TODO:fill in contents */ }
+
+ err := c.LogSync(ctx, []*eventlog.ChromeInfraLogEvent{event})
+ if err != nil {
+ fmt.Printf("logging: %v\n", err)
+ }
+}
« common/eventlog/settings.go ('K') | « common/eventlog/settings.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698