adding ability to write a log file with all output from collector. Executing commands will now log be logged (and when debug is enabled, their output's are also logged).

This commit is contained in:
Jason Kulatunga
2020-09-19 18:51:35 -06:00
parent 67d1c592a5
commit 297f0a51c5
8 changed files with 51 additions and 9 deletions
+4 -3
View File
@@ -2,6 +2,7 @@ package common_test
import (
"github.com/analogj/scrutiny/collector/pkg/common"
"github.com/sirupsen/logrus"
"github.com/stretchr/testify/require"
"os/exec"
"testing"
@@ -13,7 +14,7 @@ func TestExecCmd(t *testing.T) {
//setup
//test
result, err := common.ExecCmd("echo", []string{"hello world"}, "", nil)
result, err := common.ExecCmd(logrus.WithField("exec", "test"), "echo", []string{"hello world"}, "", nil)
//assert
require.NoError(t, err)
@@ -26,7 +27,7 @@ func TestExecCmd_Date(t *testing.T) {
//setup
//test
_, err := common.ExecCmd("date", []string{}, "", nil)
_, err := common.ExecCmd(logrus.WithField("exec", "test"), "date", []string{}, "", nil)
//assert
require.NoError(t, err)
@@ -56,7 +57,7 @@ func TestExecCmd_InvalidCommand(t *testing.T) {
//setup
//test
_, err := common.ExecCmd("invalid_binary", []string{}, "", nil)
_, err := common.ExecCmd(logrus.WithField("exec", "test"), "invalid_binary", []string{}, "", nil)
//assert
_, castOk := err.(*exec.ExitError)