-
Notifications
You must be signed in to change notification settings - Fork 528
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
[INLONG-8791][TubeMQ] Tubemq-client-go lacks log level configuration API #8793
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @smarteng, thank you for submitting a PR to InLong 💖 We will respond as soon as possible ⏳
This seems to be your first PR 🌠 Please be sure to follow our Contribution Guidelines.
If you have any questions in the meantime, you can also ask us on the InLong Discussions 🔍
@@ -77,6 +77,10 @@ func NewConsumer(config *config.Config) (Consumer, error) { | |||
if err := config.ValidateConsumer(); err != nil { | |||
return nil, err | |||
} | |||
log.SetLogLevel(config.Log.LogLevel) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What should we do if multiple consumers set Log information and the set values are inconsistent?
I personally think that the setting of the log service should be a separate operation and should not be bound to the Consumer object
@@ -39,3 +39,18 @@ var defaultConfig = &OutputConfig{ | |||
MaxAge: 3, | |||
Level: "warn", | |||
} | |||
|
|||
// SetLogLevel set log level | |||
func SetLogLevel(level string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to check whether the set value is legal and valid
} | ||
|
||
// SetLogPath set log path | ||
func SetLogPath(path string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is necessary to check that the path allowed to be set is legal, and it may be necessary to check whether there is permission to output the log
} | ||
|
||
// GetLogConfig get log config | ||
func GetLogConfig() *OutputConfig { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not appropriate to directly expose objects for external settings. It is best to add methods to operate, and then add validity checks to the set values in the methods
Prepare a Pull Request
(Change the title refer to the following example)
cfg := config.New(config.WithConsumerMasters("master"),
config.WithTopics([]{"topic"}),
config.WithGroup("group"),
config.WithLogLevel("info"),
)
c, err := client.NewConsumer(cfg)
(The following XYZ should be replaced by the actual GitHub Issue number)
Motivation
Explain here the context, and why you're making that change. What is the problem you're trying to solve?
Modifications
Describe the modifications you've done.
Verifying this change
(Please pick either of the following options)
This change is a trivial rework/code cleanup without any test coverage.
This change is already covered by existing tests, such as:
(please describe tests)
This change added tests and can be verified as follows:
(example:)
Documentation