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

Side by Side Diff: common/logging/gologger/logger.go

Issue 1622553005: Remove log filtering and add stringsetflag. (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-go@master
Patch Set: error on empty Created 4 years, 11 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 | « common/logging/filter.go ('k') | common/meter/meter.go » ('j') | 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 gologger 5 package gologger
6 6
7 import ( 7 import (
8 "bytes" 8 "bytes"
9 "fmt" 9 "fmt"
10 "strings" 10 "strings"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 case logging.Error: 74 case logging.Error:
75 li.l.Error(format, args...) 75 li.l.Error(format, args...)
76 } 76 }
77 } 77 }
78 78
79 // formatWithFields renders the supplied format string, adding fields. 79 // formatWithFields renders the supplied format string, adding fields.
80 // 80 //
81 // '%' characters in the fields string are escaped so they can't be interpreted 81 // '%' characters in the fields string are escaped so they can't be interpreted
82 // as format characters when appended to the initial format string. 82 // as format characters when appended to the initial format string.
83 func formatWithFields(format string, fields logging.Fields, args []interface{}) string { 83 func formatWithFields(format string, fields logging.Fields, args []interface{}) string {
84 » fieldString := strings.Replace(fields.FieldString(true), "%", "%%", -1) 84 » fieldString := strings.Replace(fields.String(), "%", "%%", -1)
85 85
86 buf := bytes.Buffer{} 86 buf := bytes.Buffer{}
87 buf.Grow(len(format) + logMessageFieldPadding + len(fieldString)) 87 buf.Grow(len(format) + logMessageFieldPadding + len(fieldString))
88 fmt.Fprintf(&buf, format, args...) 88 fmt.Fprintf(&buf, format, args...)
89 89
90 padding := 44 - buf.Len() 90 padding := 44 - buf.Len()
91 if padding < 1 { 91 if padding < 1 {
92 padding = 1 92 padding = 1
93 } 93 }
94 for i := 0; i < padding; i++ { 94 for i := 0; i < padding; i++ {
95 buf.WriteString(" ") 95 buf.WriteString(" ")
96 } 96 }
97 buf.WriteString(fieldString) 97 buf.WriteString(fieldString)
98 return buf.String() 98 return buf.String()
99 } 99 }
OLDNEW
« no previous file with comments | « common/logging/filter.go ('k') | common/meter/meter.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698