You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2022/03/07 12:29:18 UTC
[GitHub] [apisix-ingress-controller] Belyenochi opened a new pull request #904: feat: format gin logger
Belyenochi opened a new pull request #904:
URL: https://github.com/apache/apisix-ingress-controller/pull/904
### Type of change:
- [ ] Bugfix
- [ ] New feature provided
- [ ] Improve performance
- [ ] Backport patches
### What this PR does / why we need it:
Resloved [#899](https://github.com/apache/apisix-ingress-controller/issues/899)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-ingress-controller] Belyenochi commented on pull request #904: feat: format gin logger
Posted by GitBox <gi...@apache.org>.
Belyenochi commented on pull request #904:
URL: https://github.com/apache/apisix-ingress-controller/pull/904#issuecomment-1062498194
> Please check the CI errors
@tao12345666333, I have some doubts about the CI error. I can't reproduce it locally. It seems to be an unstable CI unit test.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-ingress-controller] lingsamuel commented on a change in pull request #904: feat: format gin logger
Posted by GitBox <gi...@apache.org>.
lingsamuel commented on a change in pull request #904:
URL: https://github.com/apache/apisix-ingress-controller/pull/904#discussion_r821375089
##########
File path: pkg/log/gin_logger.go
##########
@@ -0,0 +1,81 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package log
+
+import (
+ "net"
+ "net/http"
+ "net/http/httputil"
+ "os"
+ "runtime/debug"
+ "strings"
+ "time"
+
+ "github.com/gin-gonic/gin"
+)
+
+func GinLogger(logger *Logger) gin.HandlerFunc {
+ return func(c *gin.Context) {
+ start := time.Now()
+ path := c.Request.URL.Path
+ query := c.Request.URL.RawQuery
+ c.Next()
+ cost := time.Since(start)
+
+ logger.Infof("path: %s, status: %d, method: %s, query: %s, ip: %s, user-agent: %s, errors: %s, cost: %s",
Review comment:
I am not familiar with gin-gonic, does it have similar concept like log level? wdyt @tao12345666333 ? (this is not a change request)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-ingress-controller] Belyenochi commented on pull request #904: feat: format gin logger
Posted by GitBox <gi...@apache.org>.
Belyenochi commented on pull request #904:
URL: https://github.com/apache/apisix-ingress-controller/pull/904#issuecomment-1062503077
> @Belyenochi let me re-run CI.
It seems that everything is ok.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-ingress-controller] codecov-commenter edited a comment on pull request #904: feat: format gin logger
Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #904:
URL: https://github.com/apache/apisix-ingress-controller/pull/904#issuecomment-1061370123
# [Codecov](https://codecov.io/gh/apache/apisix-ingress-controller/pull/904?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> Merging [#904](https://codecov.io/gh/apache/apisix-ingress-controller/pull/904?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (8cf2648) into [master](https://codecov.io/gh/apache/apisix-ingress-controller/commit/8348d010507f679a17f6126e779780c76358446c?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (8348d01) will **decrease** coverage by `0.18%`.
> The diff coverage is `69.44%`.
[](https://codecov.io/gh/apache/apisix-ingress-controller/pull/904?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
```diff
@@ Coverage Diff @@
## master #904 +/- ##
==========================================
- Coverage 32.05% 31.86% -0.19%
==========================================
Files 71 72 +1
Lines 7775 7895 +120
==========================================
+ Hits 2492 2516 +24
- Misses 5009 5103 +94
- Partials 274 276 +2
```
| [Impacted Files](https://codecov.io/gh/apache/apisix-ingress-controller/pull/904?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
|---|---|---|
| [pkg/log/gin\_logger.go](https://codecov.io/gh/apache/apisix-ingress-controller/pull/904/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGtnL2xvZy9naW5fbG9nZ2VyLmdv) | `68.57% <68.57%> (ø)` | |
| [pkg/api/server.go](https://codecov.io/gh/apache/apisix-ingress-controller/pull/904/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGtnL2FwaS9zZXJ2ZXIuZ28=) | `82.27% <100.00%> (ø)` | |
| [pkg/ingress/ingress.go](https://codecov.io/gh/apache/apisix-ingress-controller/pull/904/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGtnL2luZ3Jlc3MvaW5ncmVzcy5nbw==) | `6.59% <0.00%> (-0.18%)` | :arrow_down: |
| [pkg/ingress/secret.go](https://codecov.io/gh/apache/apisix-ingress-controller/pull/904/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGtnL2luZ3Jlc3Mvc2VjcmV0Lmdv) | `0.00% <0.00%> (ø)` | |
| [pkg/ingress/status.go](https://codecov.io/gh/apache/apisix-ingress-controller/pull/904/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGtnL2luZ3Jlc3Mvc3RhdHVzLmdv) | `0.00% <0.00%> (ø)` | |
| [pkg/ingress/gateway.go](https://codecov.io/gh/apache/apisix-ingress-controller/pull/904/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGtnL2luZ3Jlc3MvZ2F0ZXdheS5nbw==) | `0.00% <0.00%> (ø)` | |
| [pkg/ingress/endpoint.go](https://codecov.io/gh/apache/apisix-ingress-controller/pull/904/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGtnL2luZ3Jlc3MvZW5kcG9pbnQuZ28=) | `0.00% <0.00%> (ø)` | |
| [pkg/ingress/apisix\_tls.go](https://codecov.io/gh/apache/apisix-ingress-controller/pull/904/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGtnL2luZ3Jlc3MvYXBpc2l4X3Rscy5nbw==) | `0.00% <0.00%> (ø)` | |
| [pkg/ingress/apisix\_route.go](https://codecov.io/gh/apache/apisix-ingress-controller/pull/904/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGtnL2luZ3Jlc3MvYXBpc2l4X3JvdXRlLmdv) | `0.00% <0.00%> (ø)` | |
| [pkg/ingress/endpointslice.go](https://codecov.io/gh/apache/apisix-ingress-controller/pull/904/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGtnL2luZ3Jlc3MvZW5kcG9pbnRzbGljZS5nbw==) | `0.00% <0.00%> (ø)` | |
| ... and [4 more](https://codecov.io/gh/apache/apisix-ingress-controller/pull/904/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/apisix-ingress-controller/pull/904?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/apisix-ingress-controller/pull/904?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [8348d01...8cf2648](https://codecov.io/gh/apache/apisix-ingress-controller/pull/904?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-ingress-controller] tao12345666333 commented on pull request #904: feat: format gin logger
Posted by GitBox <gi...@apache.org>.
tao12345666333 commented on pull request #904:
URL: https://github.com/apache/apisix-ingress-controller/pull/904#issuecomment-1062508883
merged!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-ingress-controller] lingsamuel commented on a change in pull request #904: feat: format gin logger
Posted by GitBox <gi...@apache.org>.
lingsamuel commented on a change in pull request #904:
URL: https://github.com/apache/apisix-ingress-controller/pull/904#discussion_r821375089
##########
File path: pkg/log/gin_logger.go
##########
@@ -0,0 +1,81 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package log
+
+import (
+ "net"
+ "net/http"
+ "net/http/httputil"
+ "os"
+ "runtime/debug"
+ "strings"
+ "time"
+
+ "github.com/gin-gonic/gin"
+)
+
+func GinLogger(logger *Logger) gin.HandlerFunc {
+ return func(c *gin.Context) {
+ start := time.Now()
+ path := c.Request.URL.Path
+ query := c.Request.URL.RawQuery
+ c.Next()
+ cost := time.Since(start)
+
+ logger.Infof("path: %s, status: %d, method: %s, query: %s, ip: %s, user-agent: %s, errors: %s, cost: %s",
Review comment:
I am not familiar with gin-gonic, does it have similar concept like log level? wdyt @tao12345666333 ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-ingress-controller] tao12345666333 commented on pull request #904: feat: format gin logger
Posted by GitBox <gi...@apache.org>.
tao12345666333 commented on pull request #904:
URL: https://github.com/apache/apisix-ingress-controller/pull/904#issuecomment-1062449250
Please check the CI errors
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-ingress-controller] Belyenochi commented on pull request #904: feat: format gin logger
Posted by GitBox <gi...@apache.org>.
Belyenochi commented on pull request #904:
URL: https://github.com/apache/apisix-ingress-controller/pull/904#issuecomment-1061453304
@lingsamuel, hi lingsamuel, I observed ci error, check the ingress lb status is updated, I don't know what to do to fix it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-ingress-controller] codecov-commenter commented on pull request #904: feat: format gin logger
Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on pull request #904:
URL: https://github.com/apache/apisix-ingress-controller/pull/904#issuecomment-1061370123
# [Codecov](https://codecov.io/gh/apache/apisix-ingress-controller/pull/904?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> Merging [#904](https://codecov.io/gh/apache/apisix-ingress-controller/pull/904?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (85dd532) into [master](https://codecov.io/gh/apache/apisix-ingress-controller/commit/8348d010507f679a17f6126e779780c76358446c?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (8348d01) will **decrease** coverage by `0.18%`.
> The diff coverage is `69.44%`.
[](https://codecov.io/gh/apache/apisix-ingress-controller/pull/904?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
```diff
@@ Coverage Diff @@
## master #904 +/- ##
==========================================
- Coverage 32.05% 31.86% -0.19%
==========================================
Files 71 72 +1
Lines 7775 7895 +120
==========================================
+ Hits 2492 2516 +24
- Misses 5009 5103 +94
- Partials 274 276 +2
```
| [Impacted Files](https://codecov.io/gh/apache/apisix-ingress-controller/pull/904?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
|---|---|---|
| [pkg/log/gin\_logger.go](https://codecov.io/gh/apache/apisix-ingress-controller/pull/904/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGtnL2xvZy9naW5fbG9nZ2VyLmdv) | `68.57% <68.57%> (ø)` | |
| [pkg/api/server.go](https://codecov.io/gh/apache/apisix-ingress-controller/pull/904/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGtnL2FwaS9zZXJ2ZXIuZ28=) | `82.27% <100.00%> (ø)` | |
| [pkg/ingress/ingress.go](https://codecov.io/gh/apache/apisix-ingress-controller/pull/904/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGtnL2luZ3Jlc3MvaW5ncmVzcy5nbw==) | `6.59% <0.00%> (-0.18%)` | :arrow_down: |
| [pkg/ingress/secret.go](https://codecov.io/gh/apache/apisix-ingress-controller/pull/904/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGtnL2luZ3Jlc3Mvc2VjcmV0Lmdv) | `0.00% <0.00%> (ø)` | |
| [pkg/ingress/status.go](https://codecov.io/gh/apache/apisix-ingress-controller/pull/904/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGtnL2luZ3Jlc3Mvc3RhdHVzLmdv) | `0.00% <0.00%> (ø)` | |
| [pkg/ingress/gateway.go](https://codecov.io/gh/apache/apisix-ingress-controller/pull/904/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGtnL2luZ3Jlc3MvZ2F0ZXdheS5nbw==) | `0.00% <0.00%> (ø)` | |
| [pkg/ingress/endpoint.go](https://codecov.io/gh/apache/apisix-ingress-controller/pull/904/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGtnL2luZ3Jlc3MvZW5kcG9pbnQuZ28=) | `0.00% <0.00%> (ø)` | |
| [pkg/ingress/apisix\_tls.go](https://codecov.io/gh/apache/apisix-ingress-controller/pull/904/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGtnL2luZ3Jlc3MvYXBpc2l4X3Rscy5nbw==) | `0.00% <0.00%> (ø)` | |
| [pkg/ingress/apisix\_route.go](https://codecov.io/gh/apache/apisix-ingress-controller/pull/904/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGtnL2luZ3Jlc3MvYXBpc2l4X3JvdXRlLmdv) | `0.00% <0.00%> (ø)` | |
| [pkg/ingress/endpointslice.go](https://codecov.io/gh/apache/apisix-ingress-controller/pull/904/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGtnL2luZ3Jlc3MvZW5kcG9pbnRzbGljZS5nbw==) | `0.00% <0.00%> (ø)` | |
| ... and [4 more](https://codecov.io/gh/apache/apisix-ingress-controller/pull/904/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/apisix-ingress-controller/pull/904?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/apisix-ingress-controller/pull/904?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [8348d01...85dd532](https://codecov.io/gh/apache/apisix-ingress-controller/pull/904?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-ingress-controller] lingsamuel commented on pull request #904: feat: format gin logger
Posted by GitBox <gi...@apache.org>.
lingsamuel commented on pull request #904:
URL: https://github.com/apache/apisix-ingress-controller/pull/904#issuecomment-1061466527
It's a flaky test #869, just ignore it
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-ingress-controller] Belyenochi commented on a change in pull request #904: feat: format gin logger
Posted by GitBox <gi...@apache.org>.
Belyenochi commented on a change in pull request #904:
URL: https://github.com/apache/apisix-ingress-controller/pull/904#discussion_r821417147
##########
File path: pkg/log/gin_logger.go
##########
@@ -0,0 +1,81 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package log
+
+import (
+ "net"
+ "net/http"
+ "net/http/httputil"
+ "os"
+ "runtime/debug"
+ "strings"
+ "time"
+
+ "github.com/gin-gonic/gin"
+)
+
+func GinLogger(logger *Logger) gin.HandlerFunc {
+ return func(c *gin.Context) {
+ start := time.Now()
+ path := c.Request.URL.Path
+ query := c.Request.URL.RawQuery
+ c.Next()
+ cost := time.Since(start)
+
+ logger.Infof("path: %s, status: %d, method: %s, query: %s, ip: %s, user-agent: %s, errors: %s, cost: %s",
Review comment:
@lingsamuel @tao12345666333 I used error level alone for the return codes of 4xx and 5xx.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-ingress-controller] Belyenochi commented on pull request #904: feat: format gin logger
Posted by GitBox <gi...@apache.org>.
Belyenochi commented on pull request #904:
URL: https://github.com/apache/apisix-ingress-controller/pull/904#issuecomment-1061408607
> Please fix this:
>
> > Error: ../../pkg/log/gin_logger.go:26:2: missing go.sum entry for module providing package github.com/gin-gonic/gin (imported by github.com/apache/apisix-ingress-controller/pkg/log);
>
> Thanks!
Done
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-ingress-controller] tao12345666333 commented on a change in pull request #904: feat: format gin logger
Posted by GitBox <gi...@apache.org>.
tao12345666333 commented on a change in pull request #904:
URL: https://github.com/apache/apisix-ingress-controller/pull/904#discussion_r820843043
##########
File path: pkg/log/gin_logger.go
##########
@@ -0,0 +1,67 @@
+package log
+
+import (
+ "github.com/gin-gonic/gin"
+ "net"
+ "net/http"
+ "net/http/httputil"
+ "os"
+ "runtime/debug"
+ "strings"
+ "time"
Review comment:
Please sort them.
>Imports are organized in groups, with blank lines between them. The standard library packages are always in the first group.
##########
File path: pkg/log/gin_logger.go
##########
@@ -0,0 +1,67 @@
+package log
Review comment:
We should add Apache LICENSE header. (you can copy from other files.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-ingress-controller] lingsamuel commented on pull request #904: feat: format gin logger
Posted by GitBox <gi...@apache.org>.
lingsamuel commented on pull request #904:
URL: https://github.com/apache/apisix-ingress-controller/pull/904#issuecomment-1061302955
Simply run `make update-license && make update-gofmt` to update license header and imports.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-ingress-controller] tao12345666333 commented on pull request #904: feat: format gin logger
Posted by GitBox <gi...@apache.org>.
tao12345666333 commented on pull request #904:
URL: https://github.com/apache/apisix-ingress-controller/pull/904#issuecomment-1062500055
@Belyenochi let me re-run CI.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-ingress-controller] Belyenochi commented on a change in pull request #904: feat: format gin logger
Posted by GitBox <gi...@apache.org>.
Belyenochi commented on a change in pull request #904:
URL: https://github.com/apache/apisix-ingress-controller/pull/904#discussion_r821288654
##########
File path: pkg/log/gin_logger.go
##########
@@ -0,0 +1,67 @@
+package log
+
+import (
+ "github.com/gin-gonic/gin"
+ "net"
+ "net/http"
+ "net/http/httputil"
+ "os"
+ "runtime/debug"
+ "strings"
+ "time"
Review comment:
OK
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-ingress-controller] Belyenochi commented on a change in pull request #904: feat: format gin logger
Posted by GitBox <gi...@apache.org>.
Belyenochi commented on a change in pull request #904:
URL: https://github.com/apache/apisix-ingress-controller/pull/904#discussion_r821289139
##########
File path: pkg/log/gin_logger.go
##########
@@ -0,0 +1,67 @@
+package log
Review comment:
Fixed, thanks for your review.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-ingress-controller] tao12345666333 merged pull request #904: feat: format gin logger
Posted by GitBox <gi...@apache.org>.
tao12345666333 merged pull request #904:
URL: https://github.com/apache/apisix-ingress-controller/pull/904
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-ingress-controller] Belyenochi commented on a change in pull request #904: feat: format gin logger
Posted by GitBox <gi...@apache.org>.
Belyenochi commented on a change in pull request #904:
URL: https://github.com/apache/apisix-ingress-controller/pull/904#discussion_r821283611
##########
File path: pkg/log/gin_logger.go
##########
@@ -0,0 +1,67 @@
+package log
Review comment:
> Simply run `make update-license && make update-gofmt` to update license header and imports.
Thanks!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-ingress-controller] Belyenochi commented on pull request #904: feat: format gin logger
Posted by GitBox <gi...@apache.org>.
Belyenochi commented on pull request #904:
URL: https://github.com/apache/apisix-ingress-controller/pull/904#issuecomment-1061359387
> Simply run `make update-license && make update-gofmt` to update license header and imports.
Thanks!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-ingress-controller] lingsamuel commented on pull request #904: feat: format gin logger
Posted by GitBox <gi...@apache.org>.
lingsamuel commented on pull request #904:
URL: https://github.com/apache/apisix-ingress-controller/pull/904#issuecomment-1061374813
Please fix this:
> Error: ../../pkg/log/gin_logger.go:26:2: missing go.sum entry for module providing package github.com/gin-gonic/gin (imported by github.com/apache/apisix-ingress-controller/pkg/log);
Thanks!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-ingress-controller] tao12345666333 commented on a change in pull request #904: feat: format gin logger
Posted by GitBox <gi...@apache.org>.
tao12345666333 commented on a change in pull request #904:
URL: https://github.com/apache/apisix-ingress-controller/pull/904#discussion_r821390135
##########
File path: pkg/log/gin_logger.go
##########
@@ -0,0 +1,81 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package log
+
+import (
+ "net"
+ "net/http"
+ "net/http/httputil"
+ "os"
+ "runtime/debug"
+ "strings"
+ "time"
+
+ "github.com/gin-gonic/gin"
+)
+
+func GinLogger(logger *Logger) gin.HandlerFunc {
+ return func(c *gin.Context) {
+ start := time.Now()
+ path := c.Request.URL.Path
+ query := c.Request.URL.RawQuery
+ c.Next()
+ cost := time.Since(start)
+
+ logger.Infof("path: %s, status: %d, method: %s, query: %s, ip: %s, user-agent: %s, errors: %s, cost: %s",
Review comment:
IIRC it does not provide this ability by default, but it can be achieved by customizing the Log output.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-ingress-controller] lingsamuel commented on a change in pull request #904: feat: format gin logger
Posted by GitBox <gi...@apache.org>.
lingsamuel commented on a change in pull request #904:
URL: https://github.com/apache/apisix-ingress-controller/pull/904#discussion_r821375089
##########
File path: pkg/log/gin_logger.go
##########
@@ -0,0 +1,81 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package log
+
+import (
+ "net"
+ "net/http"
+ "net/http/httputil"
+ "os"
+ "runtime/debug"
+ "strings"
+ "time"
+
+ "github.com/gin-gonic/gin"
+)
+
+func GinLogger(logger *Logger) gin.HandlerFunc {
+ return func(c *gin.Context) {
+ start := time.Now()
+ path := c.Request.URL.Path
+ query := c.Request.URL.RawQuery
+ c.Next()
+ cost := time.Since(start)
+
+ logger.Infof("path: %s, status: %d, method: %s, query: %s, ip: %s, user-agent: %s, errors: %s, cost: %s",
Review comment:
I am not familiar with gin-gonic, does it have similar concept like log level (like report error when 4XX, 5XX)? wdyt @tao12345666333 ? (this is not a change request)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org