1
0
Fork 0
mirror of https://codeberg.org/Codeberg/pages-server.git synced 2025-09-30 21:42:05 +00:00

feat: make logging interval configurable

This commit is contained in:
crapStone 2025-09-08 16:36:11 +02:00
parent 30bc87089c
commit 373044f289
No known key found for this signature in database
GPG key ID: 22D4BF0CF7CC29C8
5 changed files with 25 additions and 2 deletions

View file

@ -143,6 +143,7 @@ func TestMergeConfigShouldReplaceAllExistingValuesGivenAllArgsExist(t *testing.T
UseProxyProtocol: false,
LogMostActiveIps: false,
MostActiveIpCount: 10,
LoggingInterval: 0,
MainDomain: "original",
RawDomain: "original",
PagesBranches: []string{"original"},
@ -185,6 +186,7 @@ func TestMergeConfigShouldReplaceAllExistingValuesGivenAllArgsExist(t *testing.T
HttpServerEnabled: true,
UseProxyProtocol: true,
LogMostActiveIps: true,
LoggingInterval: 300,
MostActiveIpCount: 42,
MainDomain: "changed",
RawDomain: "changed",
@ -235,6 +237,7 @@ func TestMergeConfigShouldReplaceAllExistingValuesGivenAllArgsExist(t *testing.T
"--enable-http-server",
"--use-proxy-protocol",
"--log-most-active-ips", "42",
"--ip-logging-interval", "300",
// Forge
"--forge-root", "changed",
"--forge-api-token", "changed",
@ -288,6 +291,7 @@ func TestMergeServerConfigShouldReplaceAllExistingValuesGivenAllArgsExist(t *tes
UseProxyProtocol: false,
LogMostActiveIps: false,
MostActiveIpCount: 10,
LoggingInterval: 0,
MainDomain: "original",
RawDomain: "original",
AllowedCorsDomains: []string{"original"},
@ -304,6 +308,7 @@ func TestMergeServerConfigShouldReplaceAllExistingValuesGivenAllArgsExist(t *tes
UseProxyProtocol: true,
LogMostActiveIps: true,
MostActiveIpCount: 21,
LoggingInterval: 300,
MainDomain: "changed",
RawDomain: "changed",
AllowedCorsDomains: fixArrayFromCtx(ctx, "allowed-cors-domains", []string{"changed"}),
@ -325,6 +330,7 @@ func TestMergeServerConfigShouldReplaceAllExistingValuesGivenAllArgsExist(t *tes
"--enable-http-server",
"--use-proxy-protocol",
"--log-most-active-ips", "21",
"--ip-logging-interval", "300",
},
)
}
@ -350,6 +356,7 @@ func TestMergeServerConfigShouldReplaceOnlyOneValueExistingValueGivenOnlyOneArgE
sc.LogMostActiveIps = true
sc.MostActiveIpCount = 42
}},
{args: []string{"--ip-logging-interval", "300"}, callback: func(sc *ServerConfig) { sc.LoggingInterval = 300 }},
}
for _, pair := range testValuePairs {
@ -369,6 +376,7 @@ func TestMergeServerConfigShouldReplaceOnlyOneValueExistingValueGivenOnlyOneArgE
UseProxyProtocol: false,
LogMostActiveIps: false,
MostActiveIpCount: 10,
LoggingInterval: 0,
}
expectedConfig := cfg