mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-23 16:58:31 +02:00
refactor(config): restructured with better concurrency and error handling, reduced cross referencing
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user