OLD | NEW |
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 cloudlog | 5 package cloudlog |
6 | 6 |
7 import ( | 7 import ( |
8 "crypto/rand" | 8 "crypto/rand" |
9 "encoding/hex" | 9 "encoding/hex" |
10 "fmt" | 10 "fmt" |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 } | 95 } |
96 | 96 |
97 func (l *boundCloudLogger) LogCall(level logging.Level, calldepth int, f string,
args []interface{}) { | 97 func (l *boundCloudLogger) LogCall(level logging.Level, calldepth int, f string,
args []interface{}) { |
98 if len(f) == 0 { | 98 if len(f) == 0 { |
99 return | 99 return |
100 } | 100 } |
101 | 101 |
102 text := fmt.Sprintf(f, args...) | 102 text := fmt.Sprintf(f, args...) |
103 fields := logging.GetFields(l.ctx) | 103 fields := logging.GetFields(l.ctx) |
104 if len(fields) > 0 { | 104 if len(fields) > 0 { |
105 » » text = text + " " + fields.FieldString(true) | 105 » » text = text + " " + fields.String() |
106 } | 106 } |
107 | 107 |
108 // Add logging fields to labels. | 108 // Add logging fields to labels. |
109 entry := cloudlogging.Entry{ | 109 entry := cloudlogging.Entry{ |
110 Timestamp: clock.Now(l.ctx), | 110 Timestamp: clock.Now(l.ctx), |
111 Severity: l.getSeverity(level), | 111 Severity: l.getSeverity(level), |
112 Labels: make(map[string]string, len(fields)), | 112 Labels: make(map[string]string, len(fields)), |
113 TextPayload: text, | 113 TextPayload: text, |
114 } | 114 } |
115 | 115 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 } | 153 } |
154 | 154 |
155 // atomicCounter must be allocated separately. If embedding, use a pointer. | 155 // atomicCounter must be allocated separately. If embedding, use a pointer. |
156 // Stores current counter value. | 156 // Stores current counter value. |
157 type atomicCounter int64 | 157 type atomicCounter int64 |
158 | 158 |
159 func (c *atomicCounter) next() int64 { | 159 func (c *atomicCounter) next() int64 { |
160 nextPlusOne := atomic.AddInt64((*int64)(c), 1) | 160 nextPlusOne := atomic.AddInt64((*int64)(c), 1) |
161 return nextPlusOne - 1 | 161 return nextPlusOne - 1 |
162 } | 162 } |
OLD | NEW |