修复自定义Marshal序列化的BUG

This commit is contained in:
2025-01-22 15:55:39 +08:00
parent c00354fe46
commit 10759d9c5e
8 changed files with 48 additions and 29 deletions

View File

@ -9,15 +9,15 @@ package consts
type LogLevel string
func (ll LogLevel) String() string {
return string(ll)
func (ll *LogLevel) String() string {
return string(*ll)
}
func (ll LogLevel) MarshalJSON() ([]byte, error) {
func (ll *LogLevel) MarshalJSON() ([]byte, error) {
return []byte(ll.String()), nil
}
func (ll LogLevel) IsValid() bool {
func (ll *LogLevel) IsValid() bool {
levelList := []LogLevel{
LogLevelDebug,
LogLevelInfo,
@ -26,7 +26,7 @@ func (ll LogLevel) IsValid() bool {
LogLevelPanic,
}
for _, level := range levelList {
if level == ll {
if level == *ll {
return true
}
}