@@ -7,10 +7,10 @@ import (
77)
88
99// LogRequestStart logs the initiation of an HTTP request if the current log level permits.
10- func (d * defaultLogger ) LogRequestStart (requestID string , userID string , method string , url string , headers map [string ][]string ) {
10+ func (d * defaultLogger ) LogRequestStart (event string , requestID string , userID string , method string , url string , headers map [string ][]string ) {
1111 if d .logLevel <= LogLevelInfo {
1212 fields := []zap.Field {
13- zap .String ("event" , "request_start" ),
13+ zap .String ("event" , event ),
1414 zap .String ("method" , method ),
1515 zap .String ("url" , url ),
1616 zap .String ("request_id" , requestID ),
@@ -22,10 +22,10 @@ func (d *defaultLogger) LogRequestStart(requestID string, userID string, method
2222}
2323
2424// LogRequestEnd logs the completion of an HTTP request if the current log level permits.
25- func (d * defaultLogger ) LogRequestEnd (method string , url string , statusCode int , duration time.Duration ) {
25+ func (d * defaultLogger ) LogRequestEnd (event string , method string , url string , statusCode int , duration time.Duration ) {
2626 if d .logLevel <= LogLevelInfo {
2727 fields := []zap.Field {
28- zap .String ("event" , "request_end" ),
28+ zap .String ("event" , event ),
2929 zap .String ("method" , method ),
3030 zap .String ("url" , url ),
3131 zap .Int ("status_code" , statusCode ),
@@ -35,31 +35,31 @@ func (d *defaultLogger) LogRequestEnd(method string, url string, statusCode int,
3535 }
3636}
3737
38- // LogError logs an error that occurs during the processing of an HTTP request if the current log level permits.
39- func (d * defaultLogger ) LogError (method string , url string , statusCode int , err error , stacktrace string ) {
38+ // LogError logs an error that occurs during the processing of an HTTP request or any other event, if the current log level permits.
39+ func (d * defaultLogger ) LogError (event string , method , url string , statusCode int , err error , stacktrace string ) {
4040 if d .logLevel <= LogLevelError {
4141 errorMessage := ""
4242 if err != nil {
4343 errorMessage = err .Error ()
4444 }
4545
4646 fields := []zap.Field {
47- zap .String ("event" , "request_error" ),
47+ zap .String ("event" , event ),
4848 zap .String ("method" , method ),
4949 zap .String ("url" , url ),
5050 zap .Int ("status_code" , statusCode ),
5151 zap .String ("error_message" , errorMessage ),
5252 zap .String ("stacktrace" , stacktrace ),
5353 }
54- d .logger .Error ("Error during HTTP request " , fields ... )
54+ d .logger .Error ("Error occurred " , fields ... )
5555 }
5656}
5757
5858// LogAuthTokenError logs issues encountered during the authentication token acquisition process.
59- func (d * defaultLogger ) LogAuthTokenError (method string , url string , statusCode int , err error ) {
59+ func (d * defaultLogger ) LogAuthTokenError (event string , method string , url string , statusCode int , err error ) {
6060 if d .logLevel <= LogLevelError {
6161 fields := []zap.Field {
62- zap .String ("event" , "auth_token_error" ),
62+ zap .String ("event" , event ),
6363 zap .String ("method" , method ),
6464 zap .String ("url" , url ),
6565 zap .Int ("status_code" , statusCode ),
@@ -70,10 +70,10 @@ func (d *defaultLogger) LogAuthTokenError(method string, url string, statusCode
7070}
7171
7272// LogRetryAttempt logs a retry attempt for an HTTP request if the current log level permits, including wait duration and the error that triggered the retry.
73- func (d * defaultLogger ) LogRetryAttempt (method string , url string , attempt int , reason string , waitDuration time.Duration , err error ) {
73+ func (d * defaultLogger ) LogRetryAttempt (event string , method string , url string , attempt int , reason string , waitDuration time.Duration , err error ) {
7474 if d .logLevel <= LogLevelWarn {
7575 fields := []zap.Field {
76- zap .String ("event" , "retry_attempt" ),
76+ zap .String ("event" , event ),
7777 zap .String ("method" , method ),
7878 zap .String ("url" , url ),
7979 zap .Int ("attempt" , attempt ),
@@ -86,10 +86,10 @@ func (d *defaultLogger) LogRetryAttempt(method string, url string, attempt int,
8686}
8787
8888// LogRateLimiting logs when an HTTP request is rate-limited, including the HTTP method, URL, the value of the 'Retry-After' header, and the actual wait duration.
89- func (d * defaultLogger ) LogRateLimiting (method string , url string , retryAfter string , waitDuration time.Duration ) {
89+ func (d * defaultLogger ) LogRateLimiting (event string , method string , url string , retryAfter string , waitDuration time.Duration ) {
9090 if d .logLevel <= LogLevelWarn {
9191 fields := []zap.Field {
92- zap .String ("event" , "rate_limited" ),
92+ zap .String ("event" , event ),
9393 zap .String ("method" , method ),
9494 zap .String ("url" , url ),
9595 zap .String ("retry_after" , retryAfter ),
@@ -100,10 +100,10 @@ func (d *defaultLogger) LogRateLimiting(method string, url string, retryAfter st
100100}
101101
102102// LogResponse logs details about an HTTP response if the current log level permits.
103- func (d * defaultLogger ) LogResponse (method string , url string , statusCode int , responseBody string , responseHeaders map [string ][]string , duration time.Duration ) {
103+ func (d * defaultLogger ) LogResponse (event string , method string , url string , statusCode int , responseBody string , responseHeaders map [string ][]string , duration time.Duration ) {
104104 if d .logLevel <= LogLevelInfo {
105105 fields := []zap.Field {
106- zap .String ("event" , "response_received" ),
106+ zap .String ("event" , event ),
107107 zap .String ("method" , method ),
108108 zap .String ("url" , url ),
109109 zap .Int ("status_code" , statusCode ),
0 commit comments