@@ -144,9 +144,9 @@ func NewProxyServer(configPath string, queueSize, workerCount int) *ProxyServer
144
144
klog .V (2 ).Infof ("Got SIGQUIT signal" )
145
145
// deliver rest of queue to FINAL destination
146
146
default :
147
- klog .V (2 ).Infof ("Some signal received: %v\n " , sig )
147
+ klog .V (2 ).Infof ("Some signal received: %v" , sig )
148
148
}
149
- klog .V (1 ).Infof ("Queue len is: %v\n " , ps .getQueueLen ())
149
+ klog .V (1 ).Infof ("Queue len is: %v" , ps .getQueueLen ())
150
150
}
151
151
}()
152
152
@@ -162,12 +162,12 @@ func (p *ProxyServer) getQueueLen() int {
162
162
func (p * ProxyServer ) loadConfig () error {
163
163
data , err := ioutil .ReadFile (p .configPath )
164
164
if err != nil {
165
- klog .Fatal ("Error reading config file: %v\n " , err )
165
+ klog .Fatal ("Error reading config file: %v" , err )
166
166
}
167
167
168
168
var newConfig Config
169
169
if err := yaml .Unmarshal (data , & newConfig ); err != nil {
170
- klog .V (1 ).Infof ("Error parsing config file: %v\n " , err )
170
+ klog .V (1 ).Infof ("Error parsing config file: %v" , err )
171
171
return err
172
172
}
173
173
@@ -185,7 +185,7 @@ func (p *ProxyServer) loadConfig() error {
185
185
}
186
186
}
187
187
if ! found {
188
- klog .V (2 ).Infof ("Deleting old host %v\n " , key )
188
+ klog .V (2 ).Infof ("Deleting old host %v" , key )
189
189
p .config .Delete (key )
190
190
}
191
191
return true
@@ -214,7 +214,7 @@ func (p *ProxyServer) updateQueueLengthPeriodically() {
214
214
215
215
// worker processes requests from the queue
216
216
func (p * ProxyServer ) worker (id int ) {
217
- klog .V (2 ).Infof ("Worker %d started\n " , id )
217
+ klog .V (2 ).Infof ("Worker %d started" , id )
218
218
for req := range p .queue {
219
219
p .proxyRequest (req ) // Process each request from the queue
220
220
}
@@ -268,7 +268,7 @@ func (p *ProxyServer) proxyRequest(r *ForwardedRequest) {
268
268
269
269
if ! found || len (backends ) == 0 {
270
270
p .totalFailed .WithLabelValues (host ).Inc () // Increment failed request counter
271
- klog .V (1 ).Infof ("Error host: '%v' not found in config file, droping request\n " , host )
271
+ klog .V (1 ).Infof ("Error host: '%v' not found in config file, droping request" , host )
272
272
return
273
273
}
274
274
@@ -278,7 +278,7 @@ func (p *ProxyServer) proxyRequest(r *ForwardedRequest) {
278
278
for i := 0 ; i <= backend .Retries ; i ++ {
279
279
req , err := http .NewRequest (r .Req .Method , backend .Backend + r .Req .URL .Path , bytes .NewReader (r .Body ));
280
280
if err != nil {
281
- klog .V (4 ).Infof ("Message failed for host %s with resp code %v error: %v\n " , host , err )
281
+ klog .V (4 ).Infof ("Message failed for host %s with error: %v" , backend . Backend , err )
282
282
lastErr = err
283
283
continue
284
284
}
@@ -287,7 +287,7 @@ func (p *ProxyServer) proxyRequest(r *ForwardedRequest) {
287
287
resp , err := client .Do (req )
288
288
// Read the response body to ensure the connection can be reused
289
289
if _ , err := io .Copy (io .Discard , resp .Body ); err != nil {
290
- klog .V (1 ).Infof ("Failed to read %v response body: %v\n " , backend .Backend + r .Req .URL .Path , err )
290
+ klog .V (1 ).Infof ("Failed to read %v response body: %v" , backend .Backend + r .Req .URL .Path , err )
291
291
}
292
292
293
293
resp .Body .Close ()
@@ -296,7 +296,7 @@ func (p *ProxyServer) proxyRequest(r *ForwardedRequest) {
296
296
p .totalForwarded .WithLabelValues (host , backend .Backend ).Inc ()
297
297
return
298
298
} else {
299
- klog .V (4 ).Infof ("Message failed for host %s with resp code %v error: %v\n " , host , resp .StatusCode , err )
299
+ klog .V (4 ).Infof ("Message failed for host %s with resp code %v error: %v" , backend . Backend , resp .StatusCode , err )
300
300
}
301
301
lastErr = err
302
302
p .totalRetries .WithLabelValues (host , backend .Backend ).Inc ()
@@ -306,7 +306,7 @@ func (p *ProxyServer) proxyRequest(r *ForwardedRequest) {
306
306
307
307
// If we get here, all backends failed
308
308
p .totalFailed .WithLabelValues (host ).Inc ()
309
- klog .V (1 ).Infof ("All backends failed for host %s: %v\n " , host , lastErr )
309
+ klog .V (1 ).Infof ("All backends failed for host %s: %v" , host , lastErr )
310
310
}
311
311
312
312
// handleIncomingRequest queues incoming requests
@@ -357,15 +357,15 @@ func main() {
357
357
go func () {
358
358
metricsMux := http .NewServeMux ()
359
359
metricsMux .Handle ("/metrics" , promhttp .Handler ())
360
- klog .V (1 ).Infof ("Prometheus metrics server listening on %s\n " , conf .MetricsAddress )
360
+ klog .V (1 ).Infof ("Prometheus metrics server listening on %s" , conf .MetricsAddress )
361
361
err := http .ListenAndServe (conf .MetricsAddress , metricsMux )
362
362
if err != nil {
363
363
klog .Fatalf ("Failed to start server: %v" , err ) // %v formats the error as a string
364
364
}
365
365
}()
366
366
367
367
// Start the proxy server
368
- klog .V (1 ).Infof ("Proxy server is listening on %s\n " , conf .ListenAddress )
368
+ klog .V (1 ).Infof ("Proxy server is listening on %s" , conf .ListenAddress )
369
369
err = http .ListenAndServe (conf .ListenAddress , nil )
370
370
if err != nil {
371
371
klog .Fatalf ("Failed to start server: %v" , err ) // %v formats the error as a string
0 commit comments