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

Side by Side Diff: logdog/client/cmd/logdog_butler/main.go

Issue 2976583002: [grpc/logging] Update to LoggerV2. (Closed)
Patch Set: Created 3 years, 5 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 | « grpc/logging/grpc_logger_test.go ('k') | 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 LUCI Authors. All rights reserved. 1 // Copyright 2015 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 package main 5 package main
6 6
7 import ( 7 import (
8 "flag" 8 "flag"
9 "fmt" 9 "fmt"
10 "net/http" 10 "net/http"
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 if err := flags.Parse(argv); err != nil { 260 if err := flags.Parse(argv); err != nil {
261 log.WithError(err).Errorf(a, "Failed to parse command-line.") 261 log.WithError(err).Errorf(a, "Failed to parse command-line.")
262 return configErrorReturnCode 262 return configErrorReturnCode
263 } 263 }
264 264
265 a.Context = logConfig.Set(a.Context) 265 a.Context = logConfig.Set(a.Context)
266 266
267 // Install a global gRPC logger adapter. This routes gRPC log messages t hat 267 // Install a global gRPC logger adapter. This routes gRPC log messages t hat
268 // are emitted through our logger. We only log gRPC prints if our logger is 268 // are emitted through our logger. We only log gRPC prints if our logger is
269 // configured to log info-level or lower. 269 // configured to log info-level or lower.
270 » grpcLogging.Install(log.Get(a.Context), log.IsLogging(a.Context, log.Inf o)) 270 » logger := log.Get(a.Context)
271 » if log.IsLogging(a.Context, log.Info) {
272 » » grpcLogging.Install(logger, log.GetLevel(a.Context))
273 » } else {
274 » » // If we're not logging at INFO-level, suppress all gRPC logging output.
275 » » grpcLogging.Install(logger, grpcLogging.Suppress)
276 » }
271 277
272 if err := a.project.Validate(); err != nil { 278 if err := a.project.Validate(); err != nil {
273 log.WithError(err).Errorf(a, "Invalid project (-project).") 279 log.WithError(err).Errorf(a, "Invalid project (-project).")
274 return configErrorReturnCode 280 return configErrorReturnCode
275 } 281 }
276 282
277 // Validate our Prefix; generate a user prefix if one was not supplied. 283 // Validate our Prefix; generate a user prefix if one was not supplied.
278 prefix := a.prefix 284 prefix := a.prefix
279 if prefix == "" { 285 if prefix == "" {
280 // Auto-generate a prefix. 286 // Auto-generate a prefix.
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 350
345 paniccatcher.Do(func() { 351 paniccatcher.Do(func() {
346 rc = mainImpl(ctx, chromeinfra.DefaultAuthOptions(), os.Args[1:] ) 352 rc = mainImpl(ctx, chromeinfra.DefaultAuthOptions(), os.Args[1:] )
347 }, func(p *paniccatcher.Panic) { 353 }, func(p *paniccatcher.Panic) {
348 log.Fields{ 354 log.Fields{
349 "panic.error": p.Reason, 355 "panic.error": p.Reason,
350 }.Errorf(ctx, "Panic caught in main:\n%s", p.Stack) 356 }.Errorf(ctx, "Panic caught in main:\n%s", p.Stack)
351 rc = runtimeErrorReturnCode 357 rc = runtimeErrorReturnCode
352 }) 358 })
353 } 359 }
OLDNEW
« no previous file with comments | « grpc/logging/grpc_logger_test.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698