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
Conversation
inputs/greenplum/greenplum.go
Outdated
@@ -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) |
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.
这里不需要加 \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) |
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.
不用\n
inputs/smart/instances.go
Outdated
@@ -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) |
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.
不用 \n
inputs/smart/instances.go
Outdated
@@ -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) |
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.
\n
logs/auditor/auditor.go
Outdated
@@ -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) |
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.
\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) |
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.
这种没必要改成: 会自动有空格
logs/input/kubernetes/launcher.go
Outdated
@@ -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) |
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.
\n
logs/input/kubernetes/launcher.go
Outdated
@@ -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) |
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.
不用\n
感谢 @katepangLiu 耐心细致的工作。 PR中有多处log.Printf 不需要加\n |
好的,我清理一下 |
0a8221f
to
b678b0c
Compare
Thank you @katepangLiu |
No description provided.