Skip to content

Commit

Permalink
moved logging into main package
Browse files Browse the repository at this point in the history
  • Loading branch information
MarketDataApp committed Feb 19, 2024
1 parent dd3e983 commit 9543657
Show file tree
Hide file tree
Showing 6 changed files with 234 additions and 196 deletions.
7 changes: 6 additions & 1 deletion .scripts/gomarkdoc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@ process_group() {
echo "Markdown processing and cleanup completed for $GROUP_NAME"
}

: '
MOVE PROCESS GROUPS HERE TO AVOID PROCESSING
'

# Call process_group for each group name
process_group "indices_candles"
process_group "indices_quotes"
Expand All @@ -155,7 +160,7 @@ process_group "options_quotes"
process_group "options_strikes"
process_group "options_chain"
process_group "client"

process_group "logging"


# Add more calls to process_group with different group names as needed
Expand Down
5 changes: 4 additions & 1 deletion .scripts/process_markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
"https://www.marketdata.app/docs/api/options/strikes": {"title": "Strikes", "sidebar_position": 3},
"https://www.marketdata.app/docs/api/options/chain": {"title": "Option Chain", "sidebar_position": 4},
"https://www.marketdata.app/docs/api/options/quotes": {"title": "Quotes", "sidebar_position": 5},
"https://www.marketdata.app/docs/sdk/go/client": {"title": "Client", "sidebar_position": 3},
"https://www.marketdata.app/docs/sdk/go/client": {"title": "Client", "sidebar_position": 2},
"https://www.marketdata.app/docs/sdk/go/logging": {"title": "Logging", "sidebar_position": 3},


# Add more mappings as needed
}
Expand Down Expand Up @@ -574,6 +576,7 @@ def process_file(file_path):
content = move_responses_to_top(content)
#content = move_to_bottom(content, '<a name="Candle','<a' )
content = move_to_bottom(content, '<a name="By','<a' )
content = move_to_bottom(content, '<a name="LogEntry"></a>', '<a name="MarketDataLogs"></a>')
# content = colapse_bullet_points(content)

replacements = {
Expand Down
17 changes: 3 additions & 14 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"sync"
"time"

"github.com/MarketDataApp/sdk-go/helpers/logging"
"github.com/go-resty/resty/v2"
_ "github.com/joho/godotenv/autoload"
)
Expand Down Expand Up @@ -147,14 +146,14 @@ func (c *MarketDataClient) addLogFromRequestResponse(req *resty.Request, resp *r
body := string(resp.Body())

// Create a new log entry with the gathered information.
logEntry := logging.AddToLog(GetLogs(), time.Now(), rayID, req.URL, rateLimitConsumed, delay, status, body, redactedHeaders, resHeaders)
logEntry := addToLog(GetLogs(), time.Now(), rayID, req.URL, rateLimitConsumed, delay, status, body, redactedHeaders, resHeaders)
// If debug mode is enabled and the log entry is not nil, pretty print the log entry.
if c.debug && logEntry != nil {
logEntry.PrettyPrint()
}
// If the log entry is not nil, write it to the log.
if logEntry != nil {
logEntry.WriteToLog(c.debug)
logEntry.writeToLog(c.debug)
}
return nil
}
Expand Down Expand Up @@ -604,14 +603,4 @@ func (c *MarketDataClient) Token(bearerToken string) error {
}

return fmt.Errorf("invalid token. received non-OK status: %s", resp.Status()) // Return error for non-successful response
}

// GetLogs retrieves a pointer to the HttpRequestLogs instance, allowing access to the logs collected during HTTP requests.
// This method is primarily used for debugging and monitoring purposes, providing insights into the HTTP request lifecycle and any issues that may have occurred.
//
// # Returns
//
// - *logging.HttpRequestLogs: A pointer to the HttpRequestLogs instance containing logs of HTTP requests.
func GetLogs() *logging.HttpRequestLogs {
return logging.Logs
}
}

Check failure on line 606 in client.go

View workflow job for this annotation

GitHub Actions / build

syntax error: unexpected var after top level declaration
48 changes: 0 additions & 48 deletions helpers/logging/logging_test.go

This file was deleted.

Loading

0 comments on commit 9543657

Please sign in to comment.