Skip to content

Commit 382a1b0

Browse files
mauri870mergify[bot]
authored andcommitted
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: # filebeat/input/journald/input.go # filebeat/input/log/input.go # libbeat/autodiscover/appenders/config/config.go # libbeat/autodiscover/template/config.go # libbeat/conditions/range.go # libbeat/scripts/cmd/stress_pipeline/main.go # metricbeat/module/kafka/consumergroup/query.go # metricbeat/module/kafka/partition/partition.go # metricbeat/module/kubernetes/util/kubernetes.go # metricbeat/module/linux/rapl/rapl.go # x-pack/filebeat/input/awss3/sqs_s3_event.go # x-pack/metricbeat/module/meraki/device_health/device_health.go # x-pack/metricbeat/module/meraki/http.go # x-pack/metricbeat/module/prometheus/remote_write/data.go
1 parent 2ebe6c9 commit 382a1b0

File tree

58 files changed

+234
-79
lines changed

Some content is hidden

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

58 files changed

+234
-79
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
@@ -442,7 +442,7 @@ func (ms *MetricSet) updateKernelLostMetric(lost uint32) {
442442
}
443443
logFn("kernel lost events: %d (total: %d)", delta, lost)
444444
} else {
445-
ms.log.Warnf("kernel lost event counter reset from %d to %d", ms.kernelLost, lost)
445+
ms.log.Warnf("kernel lost event counter reset from %d to %d", ms.kernelLost.counter, lost)
446446
}
447447
ms.kernelLost.counter = lost
448448
}

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)
@@ -193,11 +193,11 @@ func (l *logHints) CreateConfig(event bus.Event, options ...ucfg.Option) []*conf
193193
moduleConf[fileset+".enabled"] = cfg.Enabled
194194
moduleConf[fileset+".input"] = filesetConf
195195

196-
l.log.Debugf("hints.builder", "generated config %+v", moduleConf)
196+
l.log.Debugf("generated config %+v", moduleConf)
197197
}
198198
config, _ = conf.NewConfigFrom(moduleConf)
199199
}
200-
l.log.Debugf("hints.builder", "generated config %+v of logHints %+v", config, l)
200+
l.log.Debugf("generated config %+v of logHints %+v", config, l)
201201
configs = append(configs, config)
202202
}
203203
// 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/journald/input.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,13 @@ func (inp *journald) Run(
205205

206206
event := entry.ToEvent()
207207
if err := publisher.Publish(event, event.Private); err != nil {
208+
<<<<<<< HEAD
208209
logger.Errorf("could not publish event: %s", err)
210+
=======
211+
msg := fmt.Sprintf("could not publish event: %s", err)
212+
ctx.UpdateStatus(status.Failed, msg)
213+
logger.Errorf("%s", msg)
214+
>>>>>>> a5be2a856 (chore: fix formatting issues in logp printf-style calls (#45944))
209215
return err
210216
}
211217
}

filebeat/input/log/input.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,11 @@ func NewInput(
106106
cleanupIfNeeded := func(f func() error) {
107107
if cleanupNeeded {
108108
if err := f(); err != nil {
109+
<<<<<<< HEAD
109110
logp.L().Named("input.log").Errorf("clean up function returned an error: %w", err)
111+
=======
112+
logger.Named("input.log").Errorf("clean up function returned an error: %v", err)
113+
>>>>>>> a5be2a856 (chore: fix formatting issues in logp printf-style calls (#45944))
110114
}
111115
}
112116
}

0 commit comments

Comments
 (0)