Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: moved sign log to info and stream output (#1276)
* fix: moved sign log to info Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * feat: stream cmd output Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * chore: fmt Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * fix: log writer Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * fix: log Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * fix: wait already closes Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * fix: wait for wg first Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * fix: use lib Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * fix: version Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
- Loading branch information
Showing
5 changed files
with
43 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package logext | ||
|
||
import "github.com/apex/log" | ||
|
||
// Writer writes with log.Info | ||
type Writer struct { | ||
ctx *log.Entry | ||
} | ||
|
||
// NewWriter creates a new log writer | ||
func NewWriter(ctx *log.Entry) Writer { | ||
return Writer{ctx: ctx} | ||
} | ||
|
||
func (t Writer) Write(p []byte) (n int, err error) { | ||
t.ctx.Info(string(p)) | ||
return len(p), nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package logext | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/apex/log" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestWriter(t *testing.T) { | ||
l, err := NewWriter(log.WithField("foo", "bar")).Write([]byte("foo bar")) | ||
require.NoError(t, err) | ||
require.Equal(t, 7, l) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters