Skip to content

Commit

Permalink
chore(log/writer): Improved log format (#139)
Browse files Browse the repository at this point in the history
* feat(log): Add writer for log

Signed-off-by: Flc゛ <four_leaf_clover@foxmail.com>

* feat(log): Add writer for log

Signed-off-by: Flc゛ <four_leaf_clover@foxmail.com>

---------

Signed-off-by: Flc゛ <four_leaf_clover@foxmail.com>
  • Loading branch information
flc1125 authored Mar 11, 2024
1 parent 494bd66 commit c39cec3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion log/writer/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ func New(logger log.Logger) *Writer {
}

func (w *Writer) Write(p []byte) (n int, err error) {
return len(p), w.logger.Log(log.LevelInfo, string(p))
return len(p), w.logger.Log(log.LevelInfo, "msg", string(p))
}
3 changes: 2 additions & 1 deletion log/writer/writer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,6 @@ func TestWriter(t *testing.T) {

d := <-result
assert.Equal(t, log.LevelInfo, d.level)
assert.Equal(t, "test", d.keyvals[0])
assert.Equal(t, "msg", d.keyvals[0])
assert.Equal(t, "test", d.keyvals[1])
}

0 comments on commit c39cec3

Please sign in to comment.