Skip to content

Commit b2e5a99

Browse files
[9.1](backport #45944) chore: fix formatting issues in logp printf-style calls (#46123)
* chore: fix formatting issues in logp printf-style calls (#45944) * fix go vet errors for logp formatting issues * chore: fix formatting for logp calls * revert elastic-agent-libs bump * Apply suggestions from code review Co-authored-by: Tiago Queiroz <[email protected]> --------- Co-authored-by: Tiago Queiroz <[email protected]> Co-authored-by: Blake Rouse <[email protected]> (cherry picked from commit a5be2a8) # Conflicts: # libbeat/autodiscover/appenders/config/config.go # libbeat/autodiscover/template/config.go # x-pack/filebeat/input/awss3/sqs_s3_event.go # x-pack/metricbeat/module/prometheus/remote_write/data.go * fix conflicts --------- Co-authored-by: Mauri de Souza Meneguzzo <[email protected]>
1 parent d9d2860 commit b2e5a99

File tree

56 files changed

+92
-92
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+92
-92
lines changed

auditbeat/helper/hasher/cached_hasher.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ func (ch *CachedHasher) HashFile(path string) (map[HashType]Digest, error) {
126126
entry := hashEntry{hashes: hashes, statx: statx}
127127
if ch.hashLRU.Add(path, entry) {
128128
ch.stats.Evictions++
129-
ch.log.Debugf("evict (%s)")
129+
ch.log.Debugf("evict (%s)", path)
130130
}
131131

132132
ch.log.Debugf("miss (%s) took %v", path, time.Since(x))

auditbeat/module/auditd/audit_linux.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ func (ms *MetricSet) updateKernelLostMetric(lost uint32) {
450450
}
451451
logFn("kernel lost events: %d (total: %d)", delta, lost)
452452
} else {
453-
ms.log.Warnf("kernel lost event counter reset from %d to %d", ms.kernelLost, lost)
453+
ms.log.Warnf("kernel lost event counter reset from %d to %d", ms.kernelLost.counter, lost)
454454
}
455455
ms.kernelLost.counter = lost
456456
}

filebeat/autodiscover/builder/hints/logs.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ func (l *logHints) CreateConfig(event bus.Event, options ...ucfg.Option) []*conf
163163
// Merge config template with the configs from the annotations
164164
// AppendValues option is used to append arrays from annotations to existing arrays while merging
165165
if err := config.MergeWithOpts(tempCfg, ucfg.AppendValues); err != nil {
166-
l.log.Debugf("hints.builder", "config merge failed with error: %v", err)
166+
l.log.Debugf("config merge failed with error: %v", err)
167167
continue
168168
}
169169
module := l.getModule(hints)
@@ -194,11 +194,11 @@ func (l *logHints) CreateConfig(event bus.Event, options ...ucfg.Option) []*conf
194194
moduleConf[fileset+".enabled"] = cfg.Enabled
195195
moduleConf[fileset+".input"] = filesetConf
196196

197-
l.log.Debugf("hints.builder", "generated config %+v", moduleConf)
197+
l.log.Debugf("generated config %+v", moduleConf)
198198
}
199199
config, _ = conf.NewConfigFrom(moduleConf)
200200
}
201-
l.log.Debugf("hints.builder", "generated config %+v of logHints %+v", config, l)
201+
l.log.Debugf("generated config %+v of logHints %+v", config, l)
202202
configs = append(configs, config)
203203
}
204204
// Apply information in event to the template to generate the final config

filebeat/input/filestream/copytruncate_prospector.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ func (p *copyTruncateFileProspector) onFSEvent(
280280

281281
err := updater.ResetCursor(src, state{Offset: 0})
282282
if err != nil {
283-
log.Errorf("failed to reset file cursor: %w", err)
283+
log.Errorf("failed to reset file cursor: %v", err)
284284
}
285285
group.Restart(ctx, src)
286286

filebeat/input/filestream/filestream.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ func (f *logFile) startFileMonitoringIfNeeded() {
142142
return nil
143143
})
144144
if err != nil {
145-
f.log.Errorf("failed to start file monitoring: %w", err)
145+
f.log.Errorf("failed to start file monitoring: %v", err)
146146
}
147147
}
148148

@@ -152,7 +152,7 @@ func (f *logFile) startFileMonitoringIfNeeded() {
152152
return nil
153153
})
154154
if err != nil {
155-
f.log.Errorf("failed to schedule a file close: %w", err)
155+
f.log.Errorf("failed to schedule a file close: %v", err)
156156
}
157157
}
158158
}

filebeat/input/filestream/internal/input-logfile/harvester.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ func (hg *defaultHarvesterGroup) Start(ctx inputv2.Context, src Source) {
140140

141141
if err := hg.tg.Go(startHarvester(ctx, hg, src, false, hg.metrics)); err != nil {
142142
ctx.Logger.Warnf(
143-
"tried to start harvester with task group already closed",
143+
"tried to start harvester for %s with task group already closed",
144144
ctx.ID)
145145
}
146146
}

filebeat/input/filestream/internal/input-logfile/publish.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ func (op *updateOp) Execute(store *store, n uint) {
134134
} else {
135135
err := typeconv.Convert(&resource.cursor, op.delta)
136136
if err != nil {
137-
store.log.Errorf("failed to perform type conversion: %w", err)
137+
store.log.Errorf("failed to perform type conversion: %v", err)
138138
}
139139
}
140140

filebeat/input/filestream/internal/input-logfile/update_writer.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func newUpdateWriter(store *store, ch *updateChan) *updateWriter {
6666
return nil
6767
})
6868
if err != nil {
69-
store.log.Errorf("failed to schedule the update writer routine: %w", err)
69+
store.log.Errorf("failed to schedule the update writer routine: %v", err)
7070
}
7171

7272
return w
@@ -77,7 +77,7 @@ func newUpdateWriter(store *store, ch *updateChan) *updateWriter {
7777
func (w *updateWriter) Close() {
7878
err := w.tg.Stop()
7979
if err != nil {
80-
w.store.log.Errorf("failed to stop the update writer routine: %w", err)
80+
w.store.log.Errorf("failed to stop the update writer routine: %v", err)
8181
}
8282
w.syncStates(w.ch.TryRecv())
8383
}

filebeat/input/filestream/prospector.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ func (p *fileProspector) onRename(log *logp.Logger, ctx input.Context, fe loginp
425425
err := s.FindCursorMeta(src, &meta)
426426
if err != nil {
427427
meta.IdentifierName = p.identifier.Name()
428-
log.Warnf("Error while getting cursor meta data of entry '%s': '%w'"+
428+
log.Warnf("Error while getting cursor meta data of entry '%s': '%v'"+
429429
", using prospector's identifier: '%s'",
430430
src.Name(), err, meta.IdentifierName)
431431
}

filebeat/input/journald/input.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ func (inp *journald) Run(
216216
if err := publisher.Publish(event, event.Private); err != nil {
217217
msg := fmt.Sprintf("could not publish event: %s", err)
218218
ctx.UpdateStatus(status.Failed, msg)
219-
logger.Errorf(msg)
219+
logger.Errorf("%s", msg)
220220
return err
221221
}
222222
}

0 commit comments

Comments
 (0)