feat: improved logging
This commit is contained in:
parent
336cd74fa4
commit
5207524381
3 changed files with 26 additions and 4 deletions
|
|
@ -27,13 +27,16 @@ func fetchRepositoriesGitlab() ([]Repository, error) {
|
|||
url := fmt.Sprintf("https://%s/api/v4/projects?%s&%s&%s%s",
|
||||
gitlabHost, membership, order, perpage, archived)
|
||||
|
||||
logPrint("Creating API request", nil)
|
||||
req, err := http.NewRequest("GET", url, nil)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("ERROR: creating request: %v\n", err)
|
||||
}
|
||||
|
||||
logPrint("Adding PRIVATE-TOKEN header to API request", nil)
|
||||
req.Header.Set("PRIVATE-TOKEN", gitlabToken)
|
||||
|
||||
logPrint("Making request", nil)
|
||||
client := &http.Client{}
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
|
|
@ -45,6 +48,7 @@ func fetchRepositoriesGitlab() ([]Repository, error) {
|
|||
return nil, fmt.Errorf("ERROR: API request failed with status: %d\n", resp.StatusCode)
|
||||
}
|
||||
|
||||
logPrint("Decoding JSON response", nil)
|
||||
var repositories []Repository
|
||||
if err := json.NewDecoder(resp.Body).Decode(&repositories); err != nil {
|
||||
return nil, fmt.Errorf("ERROR: decoding response: %v\n", err)
|
||||
|
|
@ -54,5 +58,6 @@ func fetchRepositoriesGitlab() ([]Repository, error) {
|
|||
return repositories, fmt.Errorf("ERROR: no repositories found\n")
|
||||
}
|
||||
|
||||
logPrint("Returning repositories found", nil)
|
||||
return repositories, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue