Skip to content

Commit c5ab6d4

Browse files
author
myxy99
committed
xlog
1 parent ca9ec50 commit c5ab6d4

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

xcfg/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package xcfg
22

33
import (
4+
"errors"
45
"fmt"
56
"github.com/coder2m/g-saber/xcast"
67
"io"
@@ -12,7 +13,6 @@ import (
1213

1314
"github.com/coder2m/g-saber/xtransform/xmap"
1415
"github.com/mitchellh/mapstructure"
15-
"github.com/pkg/errors"
1616
)
1717

1818
// Configuration provides configuration for application.
@@ -353,7 +353,7 @@ func (c *Configuration) UnmarshalKey(key string, rawVal interface{}, opts ...Get
353353

354354
value := c.Get(key)
355355
if value == nil {
356-
return errors.Wrap(ErrInvalidKey, key)
356+
return ErrInvalidKey
357357
}
358358

359359
return decoder.Decode(value)

xlog/log.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ func (logger *Logger) Debugf(template string, args ...interface{}) {
145145
}
146146

147147
func normalizeMessage(msg string) string {
148-
return fmt.Sprintf("%-32s", msg)
148+
return fmt.Sprintf("%-16s", msg)
149149
}
150150

151151
// Info ...

xlog/options.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
package xlog
66

77
import (
8+
"errors"
89
"fmt"
910
cfg "github.com/coder2m/g-saber/xcfg"
1011
"github.com/coder2m/g-saber/xcolor"
12+
"github.com/coder2m/g-saber/xconsole"
1113
"go.uber.org/zap"
1214
"go.uber.org/zap/zapcore"
1315
"time"
@@ -51,7 +53,11 @@ func (o *options) Filename() string {
5153
func RawConfig(key string) *options {
5254
var config = defaultConfig()
5355
if err := cfg.UnmarshalKey(key, &config); err != nil {
54-
panic(err)
56+
if errors.Is(err, cfg.ErrInvalidKey) {
57+
xconsole.Blue("xlog use default config")
58+
} else {
59+
panic(err)
60+
}
5561
}
5662
config.ConfigKey = key
5763
return config

0 commit comments

Comments
 (0)