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

Side by Side Diff: client/cmd/logdog_annotee/main.go

Issue 1812403002: Annotee: Use WithError. (Closed) Base URL: https://github.com/luci/luci-go@master
Patch Set: Created 4 years, 9 months 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package main 5 package main
6 6
7 import ( 7 import (
8 "encoding/json" 8 "encoding/json"
9 "errors" 9 "errors"
10 "flag" 10 "flag"
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 } 128 }
129 a := application{ 129 a := application{
130 Context: ctx, 130 Context: ctx,
131 annotationInterval: clockflag.Duration(defaultAnnotationInterval ), 131 annotationInterval: clockflag.Duration(defaultAnnotationInterval ),
132 } 132 }
133 133
134 // Determine bootstrapped process arguments. 134 // Determine bootstrapped process arguments.
135 var err error 135 var err error
136 a.bootstrap, err = bootstrap.Get() 136 a.bootstrap, err = bootstrap.Get()
137 if err != nil { 137 if err != nil {
138 » » log.Fields{ 138 » » log.WithError(err).Warningf(a, "Could not get LogDog Butler boot strap information.")
139 » » » log.ErrorKey: err,
140 » » }.Warningf(a, "Could not get LogDog Butler bootstrap information .")
141 } 139 }
142 140
143 fs := &flag.FlagSet{} 141 fs := &flag.FlagSet{}
144 logFlags.AddFlags(fs) 142 logFlags.AddFlags(fs)
145 a.addToFlagSet(fs) 143 a.addToFlagSet(fs)
146 if err := fs.Parse(args); err != nil { 144 if err := fs.Parse(args); err != nil {
147 » » log.Fields{ 145 » » log.WithError(err).Errorf(a, "Failed to parse flags.")
148 » » » log.ErrorKey: err,
149 » » }.Errorf(a, "Failed to parse flags.")
150 return configErrorReturnCode 146 return configErrorReturnCode
151 } 147 }
152 a.Context = logFlags.Set(a.Context) 148 a.Context = logFlags.Set(a.Context)
153 149
154 client, err := a.getStreamClient() 150 client, err := a.getStreamClient()
155 if err != nil { 151 if err != nil {
156 » » log.Fields{ 152 » » log.WithError(err).Errorf(a, "Failed to get stream client instan ce.")
157 » » » log.ErrorKey: err,
158 » » }.Errorf(a, "Failed to get stream client instance.")
159 return configErrorReturnCode 153 return configErrorReturnCode
160 } 154 }
161 155
162 prefix := types.StreamName(a.prefix) 156 prefix := types.StreamName(a.prefix)
163 if prefix == "" && a.bootstrap != nil { 157 if prefix == "" && a.bootstrap != nil {
164 prefix = a.bootstrap.Prefix 158 prefix = a.bootstrap.Prefix
165 } 159 }
166 160
167 args = fs.Args() 161 args = fs.Args()
168 if a.jsonArgsPath != "" { 162 if a.jsonArgsPath != "" {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 }, 198 },
205 199
206 Annotate: executor.AnnotationMode(a.annotate), 200 Annotate: executor.AnnotationMode(a.annotate),
207 Stdin: os.Stdin, 201 Stdin: os.Stdin,
208 } 202 }
209 if a.tee { 203 if a.tee {
210 e.TeeStdout = os.Stdout 204 e.TeeStdout = os.Stdout
211 e.TeeStderr = os.Stderr 205 e.TeeStderr = os.Stderr
212 } 206 }
213 if err := e.Run(a, args); err != nil { 207 if err := e.Run(a, args); err != nil {
214 » » log.Fields{ 208 » » log.WithError(err).Errorf(a, "Failed during execution.")
215 » » » log.ErrorKey: err,
216 » » }.Errorf(a, "Failed during execution.")
217 return runtimeErrorReturnCode 209 return runtimeErrorReturnCode
218 } 210 }
219 211
220 // Display a summary! 212 // Display a summary!
221 if a.printSummary { 213 if a.printSummary {
222 for _, s := range e.Steps() { 214 for _, s := range e.Steps() {
223 fmt.Printf("=== Annotee: %q ===\n", s.StepComponent.Name ) 215 fmt.Printf("=== Annotee: %q ===\n", s.StepComponent.Name )
224 fmt.Println(proto.MarshalTextString(s)) 216 fmt.Println(proto.MarshalTextString(s))
225 } 217 }
226 } 218 }
227 219
228 return e.ReturnCode() 220 return e.ReturnCode()
229 } 221 }
230 222
231 func main() { 223 func main() {
232 os.Exit(mainImpl(os.Args[1:])) 224 os.Exit(mainImpl(os.Args[1:]))
233 } 225 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698