v0.22.0 several enhancements and fixes for security, network, doc, test, packaging
This commit is contained in:
1 parent
9ab8c356d2
commit
71d1b82f83
102 files changed
+7102
-2178
No files matched your search
@@ -161,4 +161,3 @@ func (f *Flow) GetStats() map[string]any {
|
||||
|
||||
return stats
|
||||
}
|
||||
|
||||
@@ -137,12 +137,10 @@ func (hg *HeartbeatGenerator) generateHeartbeat(t time.Time) core.TransportEvent
|
||||
// Use flow's formatter for consistent formatting
|
||||
if adapter, ok := hg.formatter.(*format.FormatterAdapter); ok {
|
||||
// Customize flags for heartbeat if needed
|
||||
customFlags := int64(0)
|
||||
// The formatter shows a timestamp unless told otherwise
|
||||
customFlags := formatter.FlagDefault
|
||||
if !hg.config.IncludeTimestamp {
|
||||
// Remove timestamp flag if not wanted
|
||||
customFlags = formatter.FlagShowLevel
|
||||
} else {
|
||||
customFlags = formatter.FlagDefault
|
||||
customFlags = formatter.FlagShowLevel | formatter.FlagNoTimestamp
|
||||
}
|
||||
payload, err = adapter.FormatWithFlags(entry, customFlags)
|
||||
} else {
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package flow
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"logwisp/internal/config"
|
||||
"logwisp/internal/format"
|
||||
)
|
||||
|
||||
// include_timestamp = false drops the timestamp the formatter shows by default
|
||||
func TestHeartbeatTimestampFollowsIncludeTimestamp(t *testing.T) {
|
||||
at := time.Date(2026, 1, 2, 3, 4, 5, 0, time.UTC)
|
||||
for _, include := range []bool{false, true} {
|
||||
f, err := format.NewFormatter(&config.FormatConfig{Type: "txt"})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
hg, err := NewHeartbeatGenerator(&config.HeartbeatConfig{Enabled: true, IncludeTimestamp: include}, f, nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
payload := hg.generateHeartbeat(at).Payload
|
||||
if got := bytes.Contains(payload, []byte("2026-01-02")); got != include {
|
||||
t.Errorf("include_timestamp=%v: payload %q", include, payload)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -130,4 +130,4 @@ func policyString(p config.RateLimitPolicy) string {
|
||||
default:
|
||||
return "unknown"
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user