Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add logging support #389

Merged
merged 13 commits into from
Apr 22, 2024

Conversation

yuluo-yx
Copy link
Collaborator

@yuluo-yx yuluo-yx commented Apr 21, 2024

@LinuxSuRen LinuxSuRen added the enhancement New feature or request label Apr 21, 2024
@LinuxSuRen
Copy link
Owner

hi @yuluo-yx , #377 make this PR conflict status, sorry about this.

@yuluo-yx
Copy link
Collaborator Author

hi @yuluo-yx , #377 make this PR conflict status, sorry about this.

no problem, I will fix it. 🚀

Signed-off-by: yuluo-yx <[email protected]>
Signed-off-by: yuluo-yx <[email protected]>
Signed-off-by: yuluo-yx <[email protected]>
Signed-off-by: yuluo-yx <[email protected]>
@yuluo-yx
Copy link
Collaborator Author

yuluo-yx commented Apr 21, 2024

ptal @LinuxSuRen , this feat is ready for review.

Copy link
Owner

@LinuxSuRen LinuxSuRen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few suggestion. Please take a look at it.

I guess some usages are incorrect. See also:

2024-04-22T11:13:34.014+0800    DPANIC  server  cmd/server.go:236       odd number of arguments passed as key-value pairs for logging   {"ignored key": "[::]:7070"}
2024-04-22T11:13:34.014+0800    INFO    server  cmd/server.go:236       gRPC server listening at %v
2024-04-22T11:13:34.015+0800    DPANIC  server  cmd/server.go:288       odd number of arguments passed as key-value pairs for logging   {"ignored key": "[::]:8080"}
2024-04-22T11:13:34.015+0800    INFO    server  cmd/server.go:288       HTTP server listening at %v

pkg/logging/log.go Outdated Show resolved Hide resolved
pkg/generator/importer.go Outdated Show resolved Hide resolved
pkg/logging/log_test.go Outdated Show resolved Hide resolved
pkg/logging/log_test.go Outdated Show resolved Hide resolved
@yuluo-yx
Copy link
Collaborator Author

A few suggestion. Please take a look at it.

I guess some usages are incorrect. See also:

2024-04-22T11:13:34.014+0800    DPANIC  server  cmd/server.go:236       odd number of arguments passed as key-value pairs for logging   {"ignored key": "[::]:7070"}
2024-04-22T11:13:34.014+0800    INFO    server  cmd/server.go:236       gRPC server listening at %v
2024-04-22T11:13:34.015+0800    DPANIC  server  cmd/server.go:288       odd number of arguments passed as key-value pairs for logging   {"ignored key": "[::]:8080"}
2024-04-22T11:13:34.015+0800    INFO    server  cmd/server.go:288       HTTP server listening at %v

got it, I will fix it.

Signed-off-by: yuluo-yx <[email protected]>
cmd/server.go Outdated Show resolved Hide resolved
cmd/server.go Outdated Show resolved Hide resolved
cmd/server.go Outdated Show resolved Hide resolved
@@ -13,7 +13,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.20.x
go-version: 1.22.2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why specify this version instead of 1.22.x

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As of Go 1.21, toolchain versions must use the 1.N.P syntax.
go.mod does not match this syntax and there is no additional toolchain directive, which may cause some go commands to fail.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/actions/setup-go#getting-go-version-from-the-gomod-file

see here if we can just using 1.22, and it will choose the latest patch version of 1.22.x automatically.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By the way, why we need to upgrade the Go version from 1.20 to 1.22?

Copy link
Collaborator Author

@yuluo-yx yuluo-yx Apr 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By the way, why we need to upgrade the Go version from 1.20 to 1.22?

advance with the times. 😆😆
Also as the language develops, some toolchains may report errors.
see envoyproxy/gateway#3215.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/actions/setup-go#getting-go-version-from-the-gomod-file

see here if we can just using 1.22, and it will choose the latest patch version of 1.22.x automatically.

got it, let me try.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/actions/setup-go#getting-go-version-from-the-gomod-file

see here if we can just using 1.22, and it will choose the latest patch version of 1.22.x automatically.

It may be ok in action but it fails when I set it up locally, can you try to set it up locally in your area? @Ink-33

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

advance with the times.

No problem of course. It will be better if reviewers could see the specific reasons to upgrade Go version. For example:

  • performance improve
  • bugfix
  • need some new APIs
  • .etc.

Anyway, people could learn from those reasons. And this is a good to have suggestion.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/actions/setup-go#getting-go-version-from-the-gomod-file

see here if we can just using 1.22, and it will choose the latest patch version of 1.22.x automatically.

It may be ok in action but it fails when I set it up locally, can you try to set it up locally in your area? @Ink-33

Do you modify go.mod? Try to keep using 1.n.p in go.mod file and use 1.22 for github action.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you modify go.mod? Try to keep using 1.n.p in go.mod file and use 1.22 for github action.

got it, I will try.

Signed-off-by: yuluo-yx <[email protected]>
Copy link
Owner

@LinuxSuRen LinuxSuRen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to do more tests manually due to there are some dependency upgrades. It might take some time.

cmd/run.go Show resolved Hide resolved
@Ink-33
Copy link
Contributor

Ink-33 commented Apr 22, 2024

I would like to know if there is something special in this log lib you added, because I found that lots of colon were missing in the logging message🤔

@Ink-33
Copy link
Contributor

Ink-33 commented Apr 22, 2024

And I also notice that you seems like constructing logging message manually instead of logging formatted. Are there any advantages?

Signed-off-by: yuluo-yx <[email protected]>
@yuluo-yx
Copy link
Collaborator Author

I would like to know if there is something special in this log lib you added, because I found that lots of colon were missing in the logging message🤔

e.g.

xxxLogger.Info("this is a msg", "age", age, "name", name)
{"level":"info","msg":"this is a msg","age":20,"name":"test"}

@yuluo-yx
Copy link
Collaborator Author

And I also notice that you seems like constructing logging message manually instead of logging formatted. Are there any advantages?

I do not understand? Can you give an example?

@Ink-33
Copy link
Contributor

Ink-33 commented Apr 22, 2024

I would like to know if there is something special in this log lib you added, because I found that lots of colon were missing in the logging message🤔

e.g.

xxxLogger.Info("this is a msg", "age", age, "name", name)
{"level":"info","msg":"this is a msg","age":20,"name":"test"}

I got it, thanks.

@LinuxSuRen
Copy link
Owner

image

This mistake is made by me. Sorry about it.

I think this kind of log message is good for log system, but is not friendly for human reading.

@Ink-33
Copy link
Contributor

Ink-33 commented Apr 22, 2024

And I also notice that you seems like constructing logging message manually instead of logging formatted. Are there any advantages?

I do not understand? Can you give an example?

I have got that you are using structured logs so you can ingore this👍

@yuluo-yx
Copy link
Collaborator Author

I need to do more tests manually due to there are some dependency upgrades. It might take some time.

no problem, If has any problem, please call me.

Copy link

sonarcloud bot commented Apr 22, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
4.3% Duplication on New Code (required ≤ 3%)

See analysis details on SonarCloud

@LinuxSuRen
Copy link
Owner

Please ignore the report error.

image

Copy link
Owner

@LinuxSuRen LinuxSuRen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@LinuxSuRen LinuxSuRen merged commit 1943e7d into LinuxSuRen:master Apr 22, 2024
7 of 9 checks passed
@yuluo-yx yuluo-yx deleted the 0421-yuluo/add-logging branch April 22, 2024 12:23
@LinuxSuRen LinuxSuRen added the legend The contributions before they become a committer label Jun 11, 2024
LinuxSuRen pushed a commit that referenced this pull request Jun 17, 2024
* chore(deps): update redis docker tag to v6.2.13

* Update app version

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: github-action update-app-version <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request legend The contributions before they become a committer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants