Skip to content

Commit 626bdcd

Browse files
authored
Merge pull request #6 from theapsgroup/feat/logging
feat: logging
2 parents fae2784 + 44a3888 commit 626bdcd

11 files changed

Lines changed: 48 additions & 0 deletions

clickup/table_folder.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,15 @@ func listFolders(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData
3131
}
3232

3333
spaceId := d.KeyColumnQuals["space_id"].GetStringValue()
34+
plugin.Logger(ctx).Debug("listFolders", "spaceId", spaceId)
3435

3536
folders, _, err := client.Folders.GetFolders(ctx, spaceId, true)
3637
if err != nil {
38+
plugin.Logger(ctx).Error(fmt.Sprintf("unable to obtain folders for space id '%s': %v", spaceId, err))
3739
return nil, fmt.Errorf("unable to obtain folders for space id '%s': %v", spaceId, err)
3840
}
3941

42+
plugin.Logger(ctx).Debug("listFolders", "spaceId", spaceId, "results", len(folders))
4043
for _, folder := range folders {
4144
d.StreamListItem(ctx, folder)
4245
}
@@ -51,9 +54,11 @@ func getFolder(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData)
5154
}
5255

5356
folderId := d.KeyColumnQuals["id"].GetStringValue()
57+
plugin.Logger(ctx).Debug("getFolder", "id", folderId)
5458

5559
folder, _, err := client.Folders.GetFolder(ctx, folderId)
5660
if err != nil {
61+
plugin.Logger(ctx).Error(fmt.Sprintf("unable to obtain folder with id '%s': %v", folderId, err))
5762
return nil, fmt.Errorf("unable to obtain folder with id '%s': %v", folderId, err)
5863
}
5964

clickup/table_folderless_list.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,15 @@ func listFolderlessLists(ctx context.Context, d *plugin.QueryData, h *plugin.Hyd
2525
}
2626

2727
spaceId := d.KeyColumnQuals["space_id"].GetStringValue()
28+
plugin.Logger(ctx).Debug("listFolderlessLists", "spaceId", spaceId)
2829

2930
lists, _, err := client.Lists.GetFolderlessLists(ctx, spaceId, true)
3031
if err != nil {
32+
plugin.Logger(ctx).Error(fmt.Sprintf("unable to obtain folderless lists for space id '%s': %v", spaceId, err))
3133
return nil, fmt.Errorf("unable to obtain folderless lists for space id '%s': %v", spaceId, err)
3234
}
3335

36+
plugin.Logger(ctx).Debug("listFolderlessLists", "spaceId", spaceId, "results", len(lists))
3437
for _, list := range lists {
3538
d.StreamListItem(ctx, list)
3639
}

clickup/table_goal.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,21 @@ func listGoals(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData)
3131
}
3232

3333
teamId := d.KeyColumnQuals["team_id"].GetStringValue()
34+
plugin.Logger(ctx).Debug("listGoals", "teamId", teamId)
3435

3536
goals, goalFolders, _, err := client.Goals.GetGoals(ctx, teamId, true)
3637
if err != nil {
38+
plugin.Logger(ctx).Error(fmt.Sprintf("unable to obtain goals for team id '%s': %v", teamId, err))
3739
return nil, fmt.Errorf("unable to obtain goals for team id '%s': %v", teamId, err)
3840
}
3941

42+
plugin.Logger(ctx).Debug("listGoals", "teamId", teamId, "topLevelGoals", len(goals), "goalFolders", len(goalFolders))
4043
for _, goal := range goals {
4144
d.StreamListItem(ctx, goal)
4245
}
4346

4447
for _, gf := range goalFolders {
48+
plugin.Logger(ctx).Debug("listGoals", "teamId", teamId, "goalFolder", gf.Name, "goals", len(gf.Goals))
4549
for _, g := range gf.Goals {
4650
d.StreamListItem(ctx, g)
4751
}
@@ -57,9 +61,11 @@ func getGoal(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (i
5761
}
5862

5963
goalId := d.KeyColumnQuals["id"].GetStringValue()
64+
plugin.Logger(ctx).Debug("getGoal", "id", goalId)
6065

6166
goal, _, err := client.Goals.GetGoal(ctx, goalId)
6267
if err != nil {
68+
plugin.Logger(ctx).Error(fmt.Sprintf("unable to obtain goal with id '%s': %v", goalId, err))
6369
return nil, fmt.Errorf("unable to obtain goal with id '%s': %v", goalId, err)
6470
}
6571

clickup/table_list.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,15 @@ func listLists(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData)
3131
}
3232

3333
folderId := d.KeyColumnQuals["folder_id"].GetStringValue()
34+
plugin.Logger(ctx).Debug("listLists", "folderId", folderId)
3435

3536
lists, _, err := client.Lists.GetLists(ctx, folderId, true)
3637
if err != nil {
38+
plugin.Logger(ctx).Error(fmt.Sprintf("unable to obtain lists for folder id '%s': %v", folderId, err))
3739
return nil, fmt.Errorf("unable to obtain lists for folder id '%s': %v", folderId, err)
3840
}
3941

42+
plugin.Logger(ctx).Debug("listLists", "folderId", folderId, "results", len(lists))
4043
for _, list := range lists {
4144
d.StreamListItem(ctx, list)
4245
}
@@ -51,9 +54,11 @@ func getList(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (i
5154
}
5255

5356
listId := d.KeyColumnQuals["id"].GetStringValue()
57+
plugin.Logger(ctx).Debug("getList", "id", listId)
5458

5559
list, _, err := client.Lists.GetList(ctx, listId)
5660
if err != nil {
61+
plugin.Logger(ctx).Error(fmt.Sprintf("unable to obtain list with id '%s': %v", listId, err))
5762
return nil, fmt.Errorf("unable to obtain list with id '%s': %v", listId, err)
5863
}
5964

clickup/table_list_member.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,15 @@ func listListMembers(ctx context.Context, d *plugin.QueryData, h *plugin.Hydrate
2727
}
2828

2929
listId := d.KeyColumnQuals["list_id"].GetStringValue()
30+
plugin.Logger(ctx).Debug("listListMembers", "listId", listId)
3031

3132
members, _, err := client.Members.GetListMembers(ctx, listId)
3233
if err != nil {
34+
plugin.Logger(ctx).Error(fmt.Sprintf("unable to obtain members for list id '%s': %v", listId, err))
3335
return nil, fmt.Errorf("unable to obtain members for list id '%s': %v", listId, err)
3436
}
3537

38+
plugin.Logger(ctx).Debug("listListMembers", "listId", listId, "results", len(members))
3639
for _, member := range members {
3740
d.StreamListItem(ctx, member)
3841
}

clickup/table_space.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,15 @@ func listSpace(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData)
3131
}
3232

3333
teamId := d.KeyColumnQuals["team_id"].GetStringValue()
34+
plugin.Logger(ctx).Debug("listSpace", "teamId", teamId)
3435

3536
spaces, _, err := client.Spaces.GetSpaces(ctx, teamId)
3637
if err != nil {
38+
plugin.Logger(ctx).Error(fmt.Sprintf("unable to obtain spacess for team id '%s': %v", teamId, err))
3739
return nil, fmt.Errorf("unable to obtain spacess for team id '%s': %v", teamId, err)
3840
}
3941

42+
plugin.Logger(ctx).Debug("listSpace", "teamId", teamId, "results", len(spaces))
4043
for _, space := range spaces {
4144
d.StreamListItem(ctx, space)
4245
}
@@ -51,9 +54,11 @@ func getSpace(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (
5154
}
5255

5356
spaceId := d.KeyColumnQuals["id"].GetStringValue()
57+
plugin.Logger(ctx).Debug("getSpace", "id", spaceId)
5458

5559
space, _, err := client.Spaces.GetSpace(ctx, spaceId)
5660
if err != nil {
61+
plugin.Logger(ctx).Error(fmt.Sprintf("unable to obtain space with id '%s': %v", spaceId, err))
5762
return nil, fmt.Errorf("unable to obtain space with id '%s': %v", spaceId, err)
5863
}
5964

clickup/table_task.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,22 +59,29 @@ func listTasks(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData)
5959

6060
// TODO: Enhance with folderId, listId, spaceId, etc once support is captured in the SDK.
6161
if q["status"] != nil {
62+
plugin.Logger(ctx).Debug("listTasks", "status", q["status"].GetStringValue())
6263
opts.Statuses = []string{q["status"].GetStringValue()}
6364
}
6465

6566
var ts []clickup.Task
6667
for {
6768
if listId != "" {
69+
plugin.Logger(ctx).Debug("listTasks", "listId", listId, "page", opts.Page)
6870
tasks, _, err := client.Tasks.GetTasks(ctx, listId, opts)
6971
if err != nil {
72+
plugin.Logger(ctx).Error(fmt.Sprintf("unable to obtain tasks for list id '%s': %v", listId, err))
7073
return nil, fmt.Errorf("unable to obtain tasks for list id '%s': %v", listId, err)
7174
}
75+
plugin.Logger(ctx).Debug("listTasks", "listId", listId, "page", opts.Page, "results", len(tasks))
7276
ts = tasks
7377
} else {
78+
plugin.Logger(ctx).Debug("listTasks", "teamId", teamId, "page", opts.Page)
7479
tasks, _, err := client.Tasks.GetFilteredTeamTasks(ctx, teamId, opts)
7580
if err != nil {
81+
plugin.Logger(ctx).Error(fmt.Sprintf("unable to obtain tasks for team id '%s': %v", teamId, err))
7682
return nil, fmt.Errorf("unable to obtain tasks for team id '%s': %v", teamId, err)
7783
}
84+
plugin.Logger(ctx).Debug("listTasks", "teamId", teamId, "page", opts.Page, "results", len(tasks))
7885
ts = tasks
7986
}
8087

@@ -83,6 +90,7 @@ func listTasks(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData)
8390
}
8491

8592
if len(ts) < 100 {
93+
plugin.Logger(ctx).Debug("listTasks - exiting as page returned < 100 items", "page", opts.Page, "results", len(ts))
8694
break
8795
}
8896

clickup/table_task_assignee.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,17 @@ func listTaskAssignees(ctx context.Context, d *plugin.QueryData, h *plugin.Hydra
2828
}
2929

3030
taskId := d.KeyColumnQuals["task_id"].GetStringValue()
31+
plugin.Logger(ctx).Debug("listTaskAssignees", "taskId", taskId)
3132

3233
opts := &clickup.GetTaskOptions{}
3334

3435
task, _, err := client.Tasks.GetTask(ctx, taskId, opts)
3536
if err != nil {
37+
plugin.Logger(ctx).Error(fmt.Sprintf("unable to obtain task with id '%s': %v", taskId, err))
3638
return nil, fmt.Errorf("unable to obtain task with id '%s': %v", taskId, err)
3739
}
3840

41+
plugin.Logger(ctx).Debug("listTaskAssignees", "taskId", taskId, "results", len(task.Assignees))
3942
for _, assignee := range task.Assignees {
4043
d.StreamListItem(ctx, assignee)
4144
}

clickup/table_task_watcher.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,17 @@ func listTaskWatchers(ctx context.Context, d *plugin.QueryData, h *plugin.Hydrat
2626
}
2727

2828
taskId := d.KeyColumnQuals["task_id"].GetStringValue()
29+
plugin.Logger(ctx).Debug("listTaskWatchers", "taskId", taskId)
2930

3031
opts := &clickup.GetTaskOptions{}
3132

3233
task, _, err := client.Tasks.GetTask(ctx, taskId, opts)
3334
if err != nil {
35+
plugin.Logger(ctx).Error(fmt.Sprintf("unable to obtain task with id '%s': %v", taskId, err))
3436
return nil, fmt.Errorf("unable to obtain task with id '%s': %v", taskId, err)
3537
}
3638

39+
plugin.Logger(ctx).Debug("listTaskWatchers", "taskId", taskId, "results", len(task.Watchers))
3740
for _, watcher := range task.Watchers {
3841
d.StreamListItem(ctx, watcher)
3942
}

clickup/table_team.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,15 @@ func listTeams(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData)
2424
return nil, fmt.Errorf("unable to establish a connection: %v", err)
2525
}
2626

27+
plugin.Logger(ctx).Debug("listTeams")
28+
2729
teams, _, err := client.Teams.GetTeams(ctx)
2830
if err != nil {
31+
plugin.Logger(ctx).Error(fmt.Sprintf("unable to obtain teams: %v", err))
2932
return nil, fmt.Errorf("unable to obtain teams: %v", err)
3033
}
3134

35+
plugin.Logger(ctx).Debug("listTeams", "results", len(teams))
3236
for _, team := range teams {
3337
d.StreamListItem(ctx, team)
3438
}

0 commit comments

Comments
 (0)