@@ -21,7 +21,7 @@ func (e *EurekaConnection) marshal(v interface{}) ([]byte, error) {
21
21
if err != nil {
22
22
// marshal the JSON *with* indents so it's readable in the error message
23
23
out , _ := json .MarshalIndent (v , "" , " " )
24
- log .Error ("Error marshalling JSON value=%v. Error:\" %s\" JSON body=\" %s\" " , v , err .Error (), string (out ))
24
+ log .Errorf ("Error marshalling JSON value=%v. Error:\" %s\" JSON body=\" %s\" " , v , err .Error (), string (out ))
25
25
return nil , err
26
26
}
27
27
return out , nil
@@ -30,7 +30,7 @@ func (e *EurekaConnection) marshal(v interface{}) ([]byte, error) {
30
30
if err != nil {
31
31
// marshal the XML *with* indents so it's readable in the error message
32
32
out , _ := xml .MarshalIndent (v , "" , " " )
33
- log .Error ("Error marshalling XML value=%v. Error:\" %s\" JSON body=\" %s\" " , v , err .Error (), string (out ))
33
+ log .Errorf ("Error marshalling XML value=%v. Error:\" %s\" JSON body=\" %s\" " , v , err .Error (), string (out ))
34
34
return nil , err
35
35
}
36
36
return out , nil
@@ -41,18 +41,18 @@ func (e *EurekaConnection) marshal(v interface{}) ([]byte, error) {
41
41
func (e * EurekaConnection ) GetApp (name string ) (* Application , error ) {
42
42
slug := fmt .Sprintf ("%s/%s" , EurekaURLSlugs ["Apps" ], name )
43
43
reqURL := e .generateURL (slug )
44
- log .Debug ("Getting app %s from url %s" , name , reqURL )
44
+ log .Debugf ("Getting app %s from url %s" , name , reqURL )
45
45
out , rcode , err := getBody (reqURL , e .UseJson )
46
46
if err != nil {
47
- log .Error ("Couldn't get app %s, error: %s" , name , err .Error ())
47
+ log .Errorf ("Couldn't get app %s, error: %s" , name , err .Error ())
48
48
return nil , err
49
49
}
50
50
if rcode == 404 {
51
- log .Error ("App %s not found (received 404)" , name )
51
+ log .Errorf ("App %s not found (received 404)" , name )
52
52
return nil , AppNotFoundError {specific : name }
53
53
}
54
54
if rcode > 299 || rcode < 200 {
55
- log .Warning ("Non-200 rcode of %d" , rcode )
55
+ log .Warningf ("Non-200 rcode of %d" , rcode )
56
56
}
57
57
58
58
var v * Application
@@ -64,7 +64,7 @@ func (e *EurekaConnection) GetApp(name string) (*Application, error) {
64
64
err = xml .Unmarshal (out , & v )
65
65
}
66
66
if err != nil {
67
- log .Error ("Unmarshalling error: %s" , err .Error ())
67
+ log .Errorf ("Unmarshalling error: %s" , err .Error ())
68
68
return nil , err
69
69
}
70
70
@@ -84,14 +84,14 @@ func (e *EurekaConnection) readAppInto(app *Application) error {
84
84
func (e * EurekaConnection ) GetApps () (map [string ]* Application , error ) {
85
85
slug := EurekaURLSlugs ["Apps" ]
86
86
reqURL := e .generateURL (slug )
87
- log .Debug ("Getting all apps from url %s" , reqURL )
87
+ log .Debugf ("Getting all apps from url %s" , reqURL )
88
88
body , rcode , err := getBody (reqURL , e .UseJson )
89
89
if err != nil {
90
- log .Error ("Couldn't get apps, error: %s" , err .Error ())
90
+ log .Errorf ("Couldn't get apps, error: %s" , err .Error ())
91
91
return nil , err
92
92
}
93
93
if rcode > 299 || rcode < 200 {
94
- log .Warning ("Non-200 rcode of %d" , rcode )
94
+ log .Warningf ("Non-200 rcode of %d" , rcode )
95
95
}
96
96
97
97
var r * GetAppsResponse
@@ -103,7 +103,7 @@ func (e *EurekaConnection) GetApps() (map[string]*Application, error) {
103
103
err = xml .Unmarshal (body , & r )
104
104
}
105
105
if err != nil {
106
- log .Error ("Unmarshalling error: %s" , err .Error ())
106
+ log .Errorf ("Unmarshalling error: %s" , err .Error ())
107
107
return nil , err
108
108
}
109
109
@@ -112,7 +112,7 @@ func (e *EurekaConnection) GetApps() (map[string]*Application, error) {
112
112
apps [a .Name ] = r .Applications [i ]
113
113
}
114
114
for name , app := range apps {
115
- log .Debug ("Parsing metadata for app %s" , name )
115
+ log .Debugf ("Parsing metadata for app %s" , name )
116
116
app .ParseAllMetadata ()
117
117
}
118
118
return apps , nil
@@ -124,18 +124,18 @@ func (e *EurekaConnection) GetApps() (map[string]*Application, error) {
124
124
func (e * EurekaConnection ) RegisterInstance (ins * Instance ) error {
125
125
slug := fmt .Sprintf ("%s/%s" , EurekaURLSlugs ["Apps" ], ins .App )
126
126
reqURL := e .generateURL (slug )
127
- log .Debug ("Registering instance with url %s" , reqURL )
127
+ log .Debugf ("Registering instance with url %s" , reqURL )
128
128
_ , rcode , err := getBody (reqURL + "/" + ins .Id (), e .UseJson )
129
129
if err != nil {
130
- log .Error ("Failed check if Instance=%s exists in app=%s, error: %s" ,
130
+ log .Errorf ("Failed check if Instance=%s exists in app=%s, error: %s" ,
131
131
ins .Id (), ins .App , err .Error ())
132
132
return err
133
133
}
134
134
if rcode == 200 {
135
- log .Notice ("Instance=%s already exists in App=%s, aborting registration" , ins .Id (), ins .App )
135
+ log .Noticef ("Instance=%s already exists in App=%s, aborting registration" , ins .Id (), ins .App )
136
136
return nil
137
137
}
138
- log .Notice ("Instance=%s not yet registered with App=%s, registering." , ins .Id (), ins .App )
138
+ log .Noticef ("Instance=%s not yet registered with App=%s, registering." , ins .Id (), ins .App )
139
139
return e .ReregisterInstance (ins )
140
140
}
141
141
@@ -158,11 +158,11 @@ func (e *EurekaConnection) ReregisterInstance(ins *Instance) error {
158
158
159
159
body , rcode , err := postBody (reqURL , out , e .UseJson )
160
160
if err != nil {
161
- log .Error ("Could not complete registration, error: %s" , err .Error ())
161
+ log .Errorf ("Could not complete registration, error: %s" , err .Error ())
162
162
return err
163
163
}
164
164
if rcode != 204 {
165
- log .Warning ("HTTP returned %d registering Instance=%s App=%s Body=\" %s\" " , rcode ,
165
+ log .Warningf ("HTTP returned %d registering Instance=%s App=%s Body=\" %s\" " , rcode ,
166
166
ins .Id (), ins .App , string (body ))
167
167
return fmt .Errorf ("http returned %d possible failure registering instance\n " , rcode )
168
168
}
@@ -177,7 +177,7 @@ func (e *EurekaConnection) ReregisterInstance(ins *Instance) error {
177
177
func (e * EurekaConnection ) GetInstance (app , insId string ) (* Instance , error ) {
178
178
slug := fmt .Sprintf ("%s/%s/%s" , EurekaURLSlugs ["Apps" ], app , insId )
179
179
reqURL := e .generateURL (slug )
180
- log .Debug ("Getting instance with url %s" , reqURL )
180
+ log .Debugf ("Getting instance with url %s" , reqURL )
181
181
body , rcode , err := getBody (reqURL , e .UseJson )
182
182
if err != nil {
183
183
return nil , err
@@ -210,15 +210,15 @@ func (e *EurekaConnection) readInstanceInto(ins *Instance) error {
210
210
func (e * EurekaConnection ) DeregisterInstance (ins * Instance ) error {
211
211
slug := fmt .Sprintf ("%s/%s/%s" , EurekaURLSlugs ["Apps" ], ins .App , ins .Id ())
212
212
reqURL := e .generateURL (slug )
213
- log .Debug ("Deregistering instance with url %s" , reqURL )
213
+ log .Debugf ("Deregistering instance with url %s" , reqURL )
214
214
215
215
rcode , err := deleteReq (reqURL )
216
216
if err != nil {
217
- log .Error ("Could not complete deregistration, error: %s" , err .Error ())
217
+ log .Errorf ("Could not complete deregistration, error: %s" , err .Error ())
218
218
return err
219
219
}
220
220
if rcode != 204 {
221
- log .Warning ("HTTP returned %d deregistering Instance=%s App=%s" , rcode , ins .Id (), ins .App )
221
+ log .Warningf ("HTTP returned %d deregistering Instance=%s App=%s" , rcode , ins .Id (), ins .App )
222
222
return fmt .Errorf ("http returned %d possible failure deregistering instance\n " , rcode )
223
223
}
224
224
@@ -232,14 +232,14 @@ func (e EurekaConnection) AddMetadataString(ins *Instance, key, value string) er
232
232
233
233
params := map [string ]string {key : value }
234
234
235
- log .Debug ("Updating instance metadata url=%s metadata=%s" , reqURL , params )
235
+ log .Debugf ("Updating instance metadata url=%s metadata=%s" , reqURL , params )
236
236
body , rcode , err := putKV (reqURL , params )
237
237
if err != nil {
238
- log .Error ("Could not complete update, error: %s" , err .Error ())
238
+ log .Errorf ("Could not complete update, error: %s" , err .Error ())
239
239
return err
240
240
}
241
241
if rcode < 200 || rcode >= 300 {
242
- log .Warning ("HTTP returned %d updating metadata Instance=%s App=%s Body=\" %s\" " , rcode ,
242
+ log .Warningf ("HTTP returned %d updating metadata Instance=%s App=%s Body=\" %s\" " , rcode ,
243
243
ins .Id (), ins .App , string (body ))
244
244
return fmt .Errorf ("http returned %d possible failure updating instance metadata " , rcode )
245
245
}
@@ -254,14 +254,14 @@ func (e EurekaConnection) UpdateInstanceStatus(ins *Instance, status StatusType)
254
254
255
255
params := map [string ]string {"value" : string (status )}
256
256
257
- log .Debug ("Updating instance status url=%s value=%s" , reqURL , status )
257
+ log .Debugf ("Updating instance status url=%s value=%s" , reqURL , status )
258
258
body , rcode , err := putKV (reqURL , params )
259
259
if err != nil {
260
260
log .Error ("Could not complete update, error: " , err .Error ())
261
261
return err
262
262
}
263
263
if rcode < 200 || rcode >= 300 {
264
- log .Warning ("HTTP returned %d updating status Instance=%s App=%s Body=\" %s\" " , rcode ,
264
+ log .Warningf ("HTTP returned %d updating status Instance=%s App=%s Body=\" %s\" " , rcode ,
265
265
ins .Id (), ins .App , string (body ))
266
266
return fmt .Errorf ("http returned %d possible failure updating instance status " , rcode )
267
267
}
@@ -273,19 +273,19 @@ func (e EurekaConnection) UpdateInstanceStatus(ins *Instance, status StatusType)
273
273
func (e * EurekaConnection ) HeartBeatInstance (ins * Instance ) error {
274
274
slug := fmt .Sprintf ("%s/%s/%s" , EurekaURLSlugs ["Apps" ], ins .App , ins .Id ())
275
275
reqURL := e .generateURL (slug )
276
- log .Debug ("Sending heartbeat with url %s" , reqURL )
276
+ log .Debugf ("Sending heartbeat with url %s" , reqURL )
277
277
req , err := http .NewRequest ("PUT" , reqURL , nil )
278
278
if err != nil {
279
- log .Error ("Could not create request for heartbeat, error: %s" , err .Error ())
279
+ log .Errorf ("Could not create request for heartbeat, error: %s" , err .Error ())
280
280
return err
281
281
}
282
282
_ , rcode , err := netReq (req )
283
283
if err != nil {
284
- log .Error ("Error sending heartbeat for Instance=%s App=%s, error: %s" , ins .Id (), ins .App , err .Error ())
284
+ log .Errorf ("Error sending heartbeat for Instance=%s App=%s, error: %s" , ins .Id (), ins .App , err .Error ())
285
285
return err
286
286
}
287
287
if rcode != 200 {
288
- log .Error ("Sending heartbeat for Instance=%s App=%s returned code %d" , ins .Id (), ins .App , rcode )
288
+ log .Errorf ("Sending heartbeat for Instance=%s App=%s returned code %d" , ins .Id (), ins .App , rcode )
289
289
return fmt .Errorf ("heartbeat returned code %d\n " , rcode )
290
290
}
291
291
return nil
0 commit comments