5
5
use App \Model \Repository ;
6
6
use Github \Api \Issue \Labels ;
7
7
use Github \Exception \RuntimeException ;
8
+ use Psr \Log \LoggerInterface ;
8
9
use Symfony \Contracts \Cache \CacheInterface ;
9
10
use Symfony \Contracts \Cache \ItemInterface ;
10
11
@@ -30,10 +31,16 @@ class GithubLabelApi implements LabelApi
30
31
*/
31
32
private $ cache ;
32
33
33
- public function __construct (Labels $ labelsApi , CacheInterface $ cache )
34
+ /**
35
+ * @var LoggerInterface
36
+ */
37
+ private $ logger ;
38
+
39
+ public function __construct (Labels $ labelsApi , CacheInterface $ cache , LoggerInterface $ logger )
34
40
{
35
41
$ this ->labelsApi = $ labelsApi ;
36
42
$ this ->cache = $ cache ;
43
+ $ this ->logger = $ logger ;
37
44
}
38
45
39
46
public function getIssueLabels ($ issueNumber , Repository $ repository ): array
@@ -54,7 +61,10 @@ public function getIssueLabels($issueNumber, Repository $repository): array
54
61
}
55
62
}
56
63
57
- return array_keys ($ this ->labelCache [$ key ]);
64
+ $ labels = array_keys ($ this ->labelCache [$ key ]);
65
+ $ this ->logger ->debug ('Returning labels for {repo}#{issue} ' , ['repo ' => $ repository ->getFullName (), 'issue ' => $ issueNumber ]);
66
+
67
+ return $ labels ;
58
68
}
59
69
60
70
public function addIssueLabel ($ issueNumber , string $ label , Repository $ repository )
@@ -65,12 +75,8 @@ public function addIssueLabel($issueNumber, string $label, Repository $repositor
65
75
return ;
66
76
}
67
77
68
- $ this ->labelsApi ->add (
69
- $ repository ->getVendor (),
70
- $ repository ->getName (),
71
- $ issueNumber ,
72
- $ label
73
- );
78
+ $ this ->logger ->debug ('Adding label "{label}" for {repo}#{issue} ' , ['label ' => $ label , 'repo ' => $ repository ->getFullName (), 'issue ' => $ issueNumber ]);
79
+ $ this ->labelsApi ->add ($ repository ->getVendor (), $ repository ->getName (), $ issueNumber , $ label );
74
80
75
81
// Update cache if already loaded
76
82
if (isset ($ this ->labelCache [$ key ])) {
0 commit comments