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

Unified Diff: examples/eventlog/main.go

Issue 2517503002: luci-go: Basic support for event logging in Go. (Closed)
Patch Set: Add helpers for generating TypedTime 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
« no previous file with comments | « 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..89a2c3959da19a3cdd55742ab2cabb828b7324cd
--- /dev/null
+++ b/examples/eventlog/main.go
@@ -0,0 +1,31 @@
+// 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"
+
+ "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.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, event)
+ if err != nil {
+ fmt.Printf("logging: %v\n", err)
+ }
+}
« no previous file with comments | « common/eventlog/settings.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698