feat: add config to truncate long log content (#2767)

This commit is contained in:
Kevin Wan
2023-01-09 09:39:30 +08:00
committed by GitHub
parent 0defb7522f
commit 74e0676617
6 changed files with 56 additions and 6 deletions

View File

@@ -20,6 +20,8 @@ var (
timeFormat = "2006-01-02T15:04:05.000Z07:00"
logLevel uint32
encoding uint32 = jsonEncodingType
// maxContentLength is used to truncate the log content, 0 for not truncating.
maxContentLength uint32
// use uint32 for atomic operations
disableLog uint32
disableStat uint32
@@ -238,6 +240,8 @@ func SetUp(c LogConf) (err error) {
timeFormat = c.TimeFormat
}
atomic.StoreUint32(&maxContentLength, c.MaxContentLength)
switch c.Encoding {
case plainEncoding:
atomic.StoreUint32(&encoding, plainEncodingType)