File tree Expand file tree Collapse file tree 13 files changed +101
-70
lines changed
Expand file tree Collapse file tree 13 files changed +101
-70
lines changed Original file line number Diff line number Diff line change 1616
1717 - name : Run CodeQL
1818 run : |
19- docker run --rm -v $PWD:/app composer sh -c \
19+ docker run --rm -v $PWD:/app composer:2.6 sh -c \
2020 "composer install --profile --ignore-platform-reqs && composer check"
Original file line number Diff line number Diff line change 1616
1717 - name : Run Linter
1818 run : |
19- docker run --rm -v $PWD:/app composer sh -c \
19+ docker run --rm -v $PWD:/app composer:2.6 sh -c \
2020 "composer install --profile --ignore-platform-reqs && composer lint"
Original file line number Diff line number Diff line change 11/vendor /
22/.idea /
33.env
4- .phpunit.result.cache
4+ .phpunit.result.cache
5+ .DS_Store
Original file line number Diff line number Diff line change 22
33namespace Utopia \Logger \Adapter ;
44
5- use Exception ;
65use Utopia \Logger \Adapter ;
76use Utopia \Logger \Log ;
87use Utopia \Logger \Logger ;
@@ -42,8 +41,6 @@ public static function getName(): string
4241 *
4342 * @param Log $log
4443 * @return int
45- *
46- * @throws Exception
4744 */
4845 public function push (Log $ log ): int
4946 {
@@ -125,17 +122,22 @@ public function push(Log $log): int
125122 \curl_setopt_array ($ ch , $ optArray );
126123
127124 // execute request and get response
128- $ result = \curl_exec ($ ch );
129- $ response = \curl_getinfo ($ ch , \CURLINFO_HTTP_CODE );
130- $ error = \curl_error ($ ch );
125+ $ response = curl_exec ($ ch );
126+ $ httpCode = curl_getinfo ($ ch , \CURLINFO_HTTP_CODE );
127+ $ curlError = \curl_errno ($ ch );
128+ \curl_close ($ ch );
129+
130+ if ($ curlError !== CURLE_OK || $ httpCode === 0 ) {
131+ error_log ("AppSignal push failed with curl error ( {$ curlError }): {$ response }" );
131132
132- if ($ response >= 400 || $ response === 0 ) {
133- throw new Exception ("Log could not be pushed with status code {$ response }: {$ result } ( {$ error }) " );
133+ return 500 ;
134134 }
135135
136- \curl_close ($ ch );
136+ if ($ httpCode >= 400 ) {
137+ error_log ("AppSignal push failed with status code {$ httpCode }: {$ curlError } ( {$ response }) " );
138+ }
137139
138- return $ response ;
140+ return $ httpCode ;
139141 }
140142
141143 public function getSupportedTypes (): array
Original file line number Diff line number Diff line change 22
33namespace Utopia \Logger \Adapter ;
44
5- use Exception ;
65use Utopia \Logger \Adapter ;
76use Utopia \Logger \Log ;
87use Utopia \Logger \Logger ;
@@ -75,8 +74,6 @@ public static function getAdapterVersion(): string
7574 *
7675 * @param Log $log
7776 * @return int
78- *
79- * @throws Exception
8077 */
8178 public function push (Log $ log ): int
8279 {
@@ -144,17 +141,22 @@ public function push(Log $log): int
144141 \curl_setopt_array ($ ch , $ optArray );
145142
146143 // execute request and get response
147- $ result = curl_exec ($ ch );
148- $ response = curl_getinfo ($ ch , \CURLINFO_HTTP_CODE );
149- $ error = \curl_error ($ ch );
144+ $ response = curl_exec ($ ch );
145+ $ httpCode = curl_getinfo ($ ch , \CURLINFO_HTTP_CODE );
146+ $ curlError = \curl_errno ($ ch );
147+ \curl_close ($ ch );
148+
149+ if ($ curlError !== CURLE_OK || $ httpCode === 0 ) {
150+ error_log ("LogOwl push failed with curl error ( {$ curlError }): {$ response }" );
150151
151- if ($ response >= 400 || $ response === 0 ) {
152- throw new Exception ("Log could not be pushed with status code {$ response }: {$ result } ( {$ error }) " );
152+ return 500 ;
153153 }
154154
155- \curl_close ($ ch );
155+ if ($ httpCode >= 400 ) {
156+ error_log ("LogOwl push failed with status code {$ httpCode }: {$ curlError } ( {$ response }) " );
157+ }
156158
157- return $ response ;
159+ return $ httpCode ;
158160 }
159161
160162 public function getSupportedTypes (): array
Original file line number Diff line number Diff line change 22
33namespace Utopia \Logger \Adapter ;
44
5- use Exception ;
65use Utopia \Logger \Adapter ;
76use Utopia \Logger \Log ;
87use Utopia \Logger \Logger ;
@@ -42,8 +41,6 @@ public static function getName(): string
4241 *
4342 * @param Log $log
4443 * @return int
45- *
46- * @throws Exception
4744 */
4845 public function push (Log $ log ): int
4946 {
@@ -110,17 +107,22 @@ public function push(Log $log): int
110107 \curl_setopt_array ($ ch , $ optArray );
111108
112109 // execute request and get response
113- $ result = \curl_exec ($ ch );
114- $ response = \curl_getinfo ($ ch , \CURLINFO_HTTP_CODE );
115- $ error = \curl_error ($ ch );
110+ $ response = curl_exec ($ ch );
111+ $ httpCode = curl_getinfo ($ ch , \CURLINFO_HTTP_CODE );
112+ $ curlError = \curl_errno ($ ch );
113+ \curl_close ($ ch );
114+
115+ if ($ curlError !== CURLE_OK || $ httpCode === 0 ) {
116+ error_log ("Raygun push failed with curl error ( {$ curlError }): {$ response }" );
116117
117- if ($ response >= 400 || $ response === 0 ) {
118- throw new Exception ("Log could not be pushed with status code {$ response }: {$ result } ( {$ error }) " );
118+ return 500 ;
119119 }
120120
121- \curl_close ($ ch );
121+ if ($ httpCode >= 400 ) {
122+ error_log ("Raygun push failed with status code {$ httpCode }: {$ curlError } ( {$ response }) " );
123+ }
122124
123- return $ response ;
125+ return $ httpCode ;
124126 }
125127
126128 public function getSupportedTypes (): array
Original file line number Diff line number Diff line change @@ -61,8 +61,6 @@ public static function getName(): string
6161 *
6262 * @param Log $log
6363 * @return int
64- *
65- * @throws Exception
6664 */
6765 public function push (Log $ log ): int
6866 {
@@ -151,17 +149,22 @@ public function push(Log $log): int
151149 \curl_setopt_array ($ ch , $ optArray );
152150
153151 // execute request and get response
154- $ result = curl_exec ($ ch );
155- $ response = curl_getinfo ($ ch , \CURLINFO_HTTP_CODE );
156- $ error = \curl_error ($ ch );
152+ $ response = curl_exec ($ ch );
153+ $ httpCode = curl_getinfo ($ ch , \CURLINFO_HTTP_CODE );
154+ $ curlError = \curl_errno ($ ch );
155+ \curl_close ($ ch );
156+
157+ if ($ curlError !== CURLE_OK || $ httpCode === 0 ) {
158+ error_log ("Sentry push failed with curl error ( {$ curlError }): {$ response }" );
157159
158- if ($ response >= 400 || $ response === 0 ) {
159- throw new Exception ("Log could not be pushed with status code {$ response }: {$ result } ( {$ error }) " );
160+ return 500 ;
160161 }
161162
162- \curl_close ($ ch );
163+ if ($ httpCode >= 400 ) {
164+ error_log ("Sentry push failed with status code {$ httpCode }: {$ curlError } ( {$ response }) " );
165+ }
163166
164- return $ response ;
167+ return $ httpCode ;
165168 }
166169
167170 public function getSupportedTypes (): array
Original file line number Diff line number Diff line change @@ -14,5 +14,6 @@ protected function setUp(): void
1414 parent ::setUp ();
1515 $ appSignalKey = \getenv ('TEST_APPSIGNAL_KEY ' );
1616 $ this ->adapter = new AppSignal ($ appSignalKey ? $ appSignalKey : '' );
17+ $ this ->invalidAdapter = new AppSignal ('' );
1718 }
1819}
Original file line number Diff line number Diff line change @@ -12,5 +12,6 @@ protected function setUp(): void
1212 parent ::setUp ();
1313 $ logOwlKey = \getenv ('TEST_LOGOWL_KEY ' );
1414 $ this ->adapter = new LogOwl ($ logOwlKey ? $ logOwlKey : '' );
15+ $ this ->invalidAdapter = new LogOwl ('abc ' , 'https://api.invalid.io/logging/ ' );
1516 }
1617}
You can’t perform that action at this time.
0 commit comments