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

fix: log.Println log.Printf usage #743

Merged
merged 1 commit into from Dec 22, 2023

Conversation

katepangLiu
Copy link
Contributor

No description provided.

@@ -48,7 +48,7 @@ func (ins *Greenplum) Gather(slist *types.SampleList) {
stateValue = strings.TrimSpace(stateValue)
gpstate := strings.Fields(stateValue)
if len(gpstate)%7 != 0 {
log.Println("E! failed to parse gpstate -m output: %v", gpstate)
log.Printf("E! failed to parse gpstate -m output: %v\n", gpstate)
Copy link
Collaborator

Choose a reason for hiding this comment

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

这里不需要加 \n

@@ -15,7 +15,7 @@ import (
func TestGetExpvar(tb testing.TB, name string) expvar.Var {
tb.Helper()
v := expvar.Get(name)
log.Println("Var %q is %v", name, v)
log.Printf("Var %s is %v\n", name, v)
Copy link
Collaborator

Choose a reason for hiding this comment

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

不用\n

@@ -343,7 +344,7 @@ func gatherIntelNVMeDisk(slist *types.SampleList, timeout config.Duration, usesu

_, er := exitStatus(e)
if er != nil {
log.Printf("E! failed to run command '%s %s': %w - %s", nvme, strings.Join(args, " "), e, outStr)
log.Printf("E! failed to run command '%s %s': %v - %s\n", nvme, strings.Join(args, " "), e, outStr)
Copy link
Collaborator

Choose a reason for hiding this comment

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

不用 \n

@@ -412,7 +413,7 @@ func (m *Instance) gatherDisk(slist *types.SampleList, device string, wg *sync.W
// Ignore all exit statuses except if it is a command line parse error
exitStatus, er := exitStatus(e)
if er != nil {
log.Printf("E! failed to run command '%s %s': %w - %s", m.PathSmartctl, strings.Join(args, " "), e, outStr)
log.Printf("E! failed to run command '%s %s': %v - %s\n", m.PathSmartctl, strings.Join(args, " "), e, outStr)
Copy link
Collaborator

Choose a reason for hiding this comment

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

\n

@@ -187,7 +187,7 @@ func (a *RegistryAuditor) recoverRegistry() map[string]*RegistryEntry {
mr, err := ioutil.ReadFile(a.registryPath)
if err != nil {
if os.IsNotExist(err) {
log.Println("I! Could not find state file at %q, will start with default offsets", a.registryPath)
log.Printf("I! Could not find state file at %q, will start with default offsets\n", a.registryPath)
Copy link
Collaborator

Choose a reason for hiding this comment

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

\n

return false, retrier
}

// NewLauncher returns a new launcher.
func NewLauncher(sources *logsconfig.LogSources, services *service.Services, collectAll bool) *Launcher {
kubeutil, err := kubelet.GetKubeUtil()
if err != nil {
log.Printf("KubeUtil not available, failed to create launcher", err)
log.Println("KubeUtil not available, failed to create launcher: ", err)
Copy link
Collaborator

Choose a reason for hiding this comment

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

这种没必要改成: 会自动有空格

@@ -177,7 +177,7 @@ func (l *Launcher) addSource(svc *service.Service) {
if err != nil {
if errors.IsRetriable(err) {
// Attempt to reschedule the source later
log.Println("Failed to fetch pod info for container %v, will retry: %v", svc.Identifier, err)
log.Printf("Failed to fetch pod info for container %v, will retry: %v\n", svc.Identifier, err)
Copy link
Collaborator

Choose a reason for hiding this comment

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

\n

@@ -192,7 +192,7 @@ func (l *Launcher) addSource(svc *service.Service) {
source, err := l.getSource(pod, container)
if err != nil {
if err != errCollectAllDisabled {
log.Println("Invalid configuration for pod %v, container %v: %v", pod.Metadata.Name, container.Name, err)
log.Printf("Invalid configuration for pod %v, container %v: %v\n", pod.Metadata.Name, container.Name, err)
Copy link
Collaborator

Choose a reason for hiding this comment

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

不用\n

@kongfei605
Copy link
Collaborator

感谢 @katepangLiu 耐心细致的工作。 PR中有多处log.Printf 不需要加\n

@katepangLiu
Copy link
Contributor Author

感谢 @katepangLiu 耐心细致的工作。 PR中有多处log.Printf 不需要加\n

好的,我清理一下

@kongfei605
Copy link
Collaborator

Thank you @katepangLiu

@kongfei605 kongfei605 merged commit 518b41a into flashcatcloud:main Dec 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants