refactor(config): restructured with better concurrency and error handling, reduced cross referencing

This commit is contained in:
yusing
2025-10-09 01:02:24 +08:00
parent d08be872a0
commit cab68807ee
25 changed files with 720 additions and 623 deletions

View File

@@ -25,7 +25,7 @@ type (
FieldsBody []LogField
ListBody []string
MessageBody string
ErrorBody struct {
errorBody struct {
Error error
}
)
@@ -40,6 +40,10 @@ func MakeLogFields(fields ...LogField) LogBody {
return FieldsBody(fields)
}
func ErrorBody(err error) LogBody {
return errorBody{Error: err}
}
func (f *LogFormat) Parse(format string) error {
switch format {
case "":
@@ -116,7 +120,7 @@ func (m MessageBody) Format(format *LogFormat) ([]byte, error) {
return m.Format(LogFormatMarkdown)
}
func (e ErrorBody) Format(format *LogFormat) ([]byte, error) {
func (e errorBody) Format(format *LogFormat) ([]byte, error) {
switch format {
case LogFormatRawJSON:
return sonic.Marshal(e.Error)