Skip to content

Commit 3eebdbc

Browse files
authored
Add configuration option to print logs (#134)
1 parent 6215ef9 commit 3eebdbc

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

README.adoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,9 @@ namespace "app1" {
274274
]
275275
}
276276

277+
# log can be printed to std out, e.g. for debugging purposes (disabled by default)
278+
print_log = false
279+
277280
# metrics_override = { prefix = "myprefix" }
278281
# namespace_label = "vhost"
279282

config/struct_namespace.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ type NamespaceConfig struct {
2424
RelabelConfigs []RelabelConfig `hcl:"relabel" yaml:"relabel_configs"`
2525
HistogramBuckets []float64 `hcl:"histogram_buckets" yaml:"histogram_buckets"`
2626

27+
PrintLog bool `hcl:"print_log" yaml:"print_log"`
28+
2729
OrderedLabelNames []string
2830
OrderedLabelValues []string
2931
}

main.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,10 @@ func processSource(nsCfg config.NamespaceConfig, t tail.Follower, parser *gonx.P
339339
}
340340

341341
for line := range t.Lines() {
342+
if nsCfg.PrintLog {
343+
fmt.Println(line)
344+
}
345+
342346
entry, err := parser.ParseString(line)
343347
if err != nil {
344348
fmt.Printf("error while parsing line '%s': %s\n", line, err)

0 commit comments

Comments
 (0)