Skip to content

Commit a9591a4

Browse files
authored
Merge branch 'master' into feat/meshmodel-summary-filters-registry-api
2 parents 8ede13d + 8dab599 commit a9591a4

File tree

9 files changed

+250
-43
lines changed

9 files changed

+250
-43
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,5 @@ assignees: ''
3434
- 🛠 [Meshery Build & Release Strategy](https://docs.meshery.io/project/contributing/build-and-release)
3535
- 📚 [Instructions for contributing to documentation](https://github.com/meshery/meshery/blob/master/CONTRIBUTING.md#documentation-contribution-flow)
3636
- Meshery documentation [site](https://docs.meshery.io/) and [source](https://github.com/meshery/meshery/tree/master/docs)
37-
- 🎨 Wireframes and [designs for Meshery UI](https://www.figma.com/file/SMP3zxOjZztdOLtgN4dS2W/Meshery-UI) in Figma [(open invite)](https://www.figma.com/team_invite/redeem/qJy1c95qirjgWQODApilR9)
37+
- 🎨 Wireframes and [designs for Meshery UI](https://www.figma.com/file/SMP3zxOjZztdOLtgN4dS2W/Meshery-UI) in Figma [(open invite)](https://www.figma.com/team_invite/redeem/GvB8SudhEOoq3JOvoLaoMs)
3838
- 🙋🏾🙋🏼 Questions: [Discussion Forum](http://discuss.meshery.io) and [Community Slack](https://slack.meshery.io)

.golangci.yml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,7 @@ version: "2"
33
run:
44
timeout: 5m
55

6-
linters-settings:
7-
staticcheck:
8-
go: "1.25"
9-
checks: ["all", "-ST1005"]
10-
11-
issues:
12-
exclude:
13-
- "ST1005"
6+
linters:
7+
settings:
8+
staticcheck:
9+
checks: ["all", "-ST1005"]

logger/controller.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,13 @@ func (c *Controller) V(level int) *Controller {
4646
}
4747

4848
func (c *Controller) WithValues(keysAndValues ...interface{}) logr.LogSink {
49-
c.base.handler.Log(logrus.InfoLevel, keysAndValues...)
49+
c.base.defaultHandler.Log(logrus.InfoLevel, keysAndValues...)
50+
c.base.errorHandler.Log(logrus.ErrorLevel, keysAndValues...)
5051
return c
5152
}
5253

5354
func (c *Controller) WithName(name string) logr.LogSink {
54-
c.base.handler.WithField("name", name)
55+
c.base.defaultHandler.WithField("name", name)
56+
c.base.errorHandler.WithField("name", name)
5557
return c
5658
}

logger/database.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,18 @@ func (c *Database) LogMode(level gormlogger.LogLevel) gormlogger.Interface {
2424
return c
2525
}
2626
func (c *Database) Info(ctx context.Context, msg string, data ...interface{}) {
27-
c.base.handler.Log(logrus.InfoLevel,
28-
"msg", data,
27+
c.base.defaultHandler.Log(logrus.InfoLevel,
28+
msg, data,
2929
)
3030
}
3131
func (c *Database) Warn(ctx context.Context, msg string, data ...interface{}) {
32-
c.base.handler.Log(logrus.WarnLevel,
33-
"msg", data,
32+
c.base.defaultHandler.Log(logrus.WarnLevel,
33+
msg, data,
3434
)
3535
}
3636
func (c *Database) Error(ctx context.Context, msg string, data ...interface{}) {
37-
c.base.handler.Log(logrus.ErrorLevel,
38-
"msg", data,
37+
c.base.errorHandler.Log(logrus.ErrorLevel,
38+
msg, data,
3939
)
4040
}
4141
func (c *Database) Trace(ctx context.Context, begin time.Time, fc func() (string, int64), err error) {

logger/logger.go

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ type Handler interface {
3232
}
3333

3434
type Logger struct {
35-
handler *logrus.Entry
35+
defaultHandler *logrus.Entry
36+
errorHandler *logrus.Entry
3637
}
3738

3839
// TerminalFormatter is exported
@@ -54,7 +55,7 @@ func (f *TerminalFormatter) Format(entry *logrus.Entry) ([]byte, error) {
5455
return append([]byte(msg), '\n'), nil
5556
}
5657

57-
func New(appname string, opts Options) (Handler, error) {
58+
func newLogrusLogger(appname string, opts Options, defaultOutput io.Writer) *logrus.Entry {
5859
log := logrus.New()
5960

6061
switch opts.Format {
@@ -81,43 +82,52 @@ func New(appname string, opts Options) (Handler, error) {
8182
log.AddHook(&CallerHook{skippedPaths: skippedPaths})
8283
}
8384

84-
log.SetOutput(os.Stdout)
85+
log.SetOutput(defaultOutput)
8586
if opts.Output != nil {
8687
log.SetOutput(opts.Output)
8788
}
8889

90+
if opts.ErrorOutput != nil {
91+
log.SetOutput(opts.ErrorOutput)
92+
}
93+
8994
log.SetLevel(logrus.Level(opts.LogLevel))
9095

91-
entry := log.WithFields(logrus.Fields{"app": appname})
92-
return &Logger{handler: entry}, nil
96+
return log.WithFields(logrus.Fields{"app": appname})
97+
}
98+
99+
func New(appname string, opts Options) (Handler, error) {
100+
entry := newLogrusLogger(appname, opts, os.Stdout)
101+
errEntry := newLogrusLogger(appname, opts, os.Stderr)
102+
return &Logger{defaultHandler: entry, errorHandler: errEntry}, nil
93103
}
94104

95105
func (l *Logger) Info(description ...interface{}) {
96-
l.handler.Log(logrus.InfoLevel,
106+
l.defaultHandler.Log(logrus.InfoLevel,
97107
description...,
98108
)
99109
}
100110

101111
func (l *Logger) Infof(format string, args ...interface{}) {
102-
l.handler.Log(logrus.InfoLevel, fmt.Sprintf(format, args...))
112+
l.defaultHandler.Log(logrus.InfoLevel, fmt.Sprintf(format, args...))
103113
}
104114

105115
func (l *Logger) Debug(description ...interface{}) {
106-
l.handler.Log(logrus.DebugLevel,
116+
l.defaultHandler.Log(logrus.DebugLevel,
107117
description...,
108118
)
109119
}
110120

111121
func (l *Logger) Debugf(format string, args ...interface{}) {
112-
l.handler.Log(logrus.DebugLevel, fmt.Sprintf(format, args...))
122+
l.defaultHandler.Log(logrus.DebugLevel, fmt.Sprintf(format, args...))
113123
}
114124

115125
func (l *Logger) Warn(err error) {
116126
if err == nil {
117127
return
118128
}
119129

120-
l.handler.WithFields(logrus.Fields{
130+
l.defaultHandler.WithFields(logrus.Fields{
121131
"code": errors.GetCode(err),
122132
"severity": errors.GetSeverity(err),
123133
"short-description": errors.GetSDescription(err),
@@ -127,15 +137,15 @@ func (l *Logger) Warn(err error) {
127137
}
128138

129139
func (l *Logger) Warnf(format string, args ...interface{}) {
130-
l.handler.Log(logrus.WarnLevel, fmt.Sprintf(format, args...))
140+
l.defaultHandler.Log(logrus.WarnLevel, fmt.Sprintf(format, args...))
131141
}
132142

133143
func (l *Logger) Error(err error) {
134144
if err == nil {
135145
return
136146
}
137147

138-
l.handler.WithFields(logrus.Fields{
148+
l.errorHandler.WithFields(logrus.Fields{
139149
"code": errors.GetCode(err),
140150
"severity": errors.GetSeverity(err),
141151
"short-description": errors.GetSDescription(err),
@@ -145,15 +155,15 @@ func (l *Logger) Error(err error) {
145155
}
146156

147157
func (l *Logger) Errorf(format string, args ...interface{}) {
148-
l.handler.Log(logrus.ErrorLevel, fmt.Sprintf(format, args...))
158+
l.errorHandler.Log(logrus.ErrorLevel, fmt.Sprintf(format, args...))
149159
}
150160

151161
func (l *Logger) Fatal(err error) {
152162
if err == nil {
153163
return
154164
}
155165

156-
l.handler.WithFields(logrus.Fields{
166+
l.errorHandler.WithFields(logrus.Fields{
157167
"code": errors.GetCode(err),
158168
"severity": errors.GetSeverity(err),
159169
"short-description": errors.GetSDescription(err),
@@ -164,18 +174,23 @@ func (l *Logger) Fatal(err error) {
164174
}
165175

166176
func (l *Logger) Fatalf(format string, args ...interface{}) {
167-
l.handler.Log(logrus.FatalLevel, fmt.Sprintf(format, args...))
177+
l.errorHandler.Log(logrus.FatalLevel, fmt.Sprintf(format, args...))
168178
os.Exit(1)
169179
}
170180

171181
func (l *Logger) SetLevel(level logrus.Level) {
172-
l.handler.Logger.SetLevel(level)
182+
l.defaultHandler.Logger.SetLevel(level)
183+
l.errorHandler.Logger.SetLevel(level)
173184
}
174185

175186
func (l *Logger) GetLevel() logrus.Level {
176-
return l.handler.Logger.GetLevel()
187+
return l.defaultHandler.Logger.GetLevel()
177188
}
178189

179190
func (l *Logger) UpdateLogOutput(output io.Writer) {
180-
l.handler.Logger.SetOutput(output)
191+
l.defaultHandler.Logger.SetOutput(output)
192+
}
193+
194+
func (l *Logger) UpdateErrorLogOutput(output io.Writer) {
195+
l.errorHandler.Logger.SetOutput(output)
181196
}

0 commit comments

Comments
 (0)