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

style(example): optimize the log output format #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions example/admin/TalosAdminDemo.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,71 +74,71 @@ func (demo TalosAdminDemo) createTopic() *topic.CreateTopicResponse {

response, err := demo.talosAdmin.CreateTopic(request)
if err != nil {
log.Error("createTopic failed: %s", topicName)
log.Errorf("createTopic failed: %s", topicName)
return nil
}
log.Info("createTopic sucess: %s", topicName)
log.Infof("createTopic success: %s", topicName)
return response
}

// get topicTalosResourceName by topicName
func (demo TalosAdminDemo) getTopicTalosResourceName() (
*topic.TopicTalosResourceName, error) {
topic, err := demo.talosAdmin.DescribeTopic(&topic.
DescribeTopicRequest{TopicName: topicName})
DescribeTopicRequest{TopicName: topicName})
if err != nil {
log.Error("getTopicTalosResourceName failed: %s", topicName)
return nil, err
}
resourceName := topic.GetTopicInfo().GetTopicTalosResourceName()
log.Info("Topic resource is: %s", resourceName.String())
log.Infof("Topic resource is: %s", resourceName.String())
return resourceName, err
}

func (demo TalosAdminDemo) deleteTopic(resourceName *topic.TopicTalosResourceName) error {
request := &topic.DeleteTopicRequest{TopicTalosResourceName: resourceName}
err := demo.talosAdmin.DeleteTopic(request)
if err != nil {
log.Error("Topic failed to delete: %s", resourceName)
log.Errorf("Topic failed to delete: %s", resourceName.String())
return err
}
log.Info("Topic success to delete: %s", resourceName)
log.Infof("Topic success to delete: %s", resourceName.String())
return err
}

func (demo TalosAdminDemo) getTopicOffset(resourceName *topic.TopicTalosResourceName) error {
request := &message.GetTopicOffsetRequest{TopicTalosResourceName: resourceName}
offsetInfoList, err := demo.talosAdmin.GetTopicOffset(request)
if err != nil {
log.Error("Topic failed to getTopicOffset: %s", resourceName)
log.Errorf("Topic failed to getTopicOffset: %s", resourceName.String())
return err
}
log.Info("Topic success to getTopicOffset: %s", offsetInfoList)
log.Infof("Topic success to getTopicOffset: %#v", offsetInfoList)
return err
}

func (demo TalosAdminDemo) listTopics() ([]*topic.TopicInfo, error) {
topicInfoList, err := demo.talosAdmin.ListTopics()
if err != nil {
log.Error("Topic failed to listTopics: %s")
log.Errorf("Topic failed to listTopics: %#v", topicInfoList)
return nil, err
}
log.Info("Topic success to listTopics: %s", topicInfoList)
log.Infof("Topic success to listTopics: %#v", topicInfoList)
for _, topic := range topicInfoList {
log.Info("Topic info: %s", topic)
log.Infof("Topic info: %#v", topic)
}
return topicInfoList, err
}

func (demo TalosAdminDemo) listTopicsInfo() ([]*topic.Topic, error) {
topicInfoList, err := demo.talosAdmin.ListTopicsInfo()
if err != nil {
log.Error("Topic failed to listTopics: %s")
log.Errorf("Topic failed to listTopics: %#v", topicInfoList)
return nil, err
}
log.Info("Topic success to listTopics: %s", topicInfoList)
log.Infof("Topic success to listTopics: %#v", topicInfoList)
for _, topicInfo := range topicInfoList {
log.Info("Topic info: %s", topicInfo)
log.Infof("Topic info: %#v", topicInfo)
}
return topicInfoList, err
}
Expand Down