Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

log checkpoint followup + dns checkup tests #1410

Merged
merged 9 commits into from
Oct 17, 2023
7 changes: 1 addition & 6 deletions cmd/launcher/launcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ import (
"github.com/kolide/launcher/pkg/debug"
"github.com/kolide/launcher/pkg/debug/checkups"
"github.com/kolide/launcher/pkg/launcher"
"github.com/kolide/launcher/pkg/log/locallogger"
"github.com/kolide/launcher/pkg/log/logshipper"
"github.com/kolide/launcher/pkg/log/teelogger"
"github.com/kolide/launcher/pkg/osquery"
Expand Down Expand Up @@ -211,11 +210,7 @@ func runLauncher(ctx context.Context, cancel func(), opts *launcher.Options) err
runGroup := rungroup.NewRunGroup(logger)

// Add the log checkpoints to the rungroup, and run it once early, to try to get data into the logs.
checkpointLogger := log.With(logutil.NewServerLogger(true))
checkpointer := checkups.NewCheckupLogger(
teelogger.New(checkpointLogger, locallogger.NewKitLogger(filepath.Join(opts.RootDirectory, "debug.json"))),
k,
)
checkpointer := checkups.NewCheckupLogger(logger, k)
checkpointer.Once(ctx)
runGroup.Add("logcheckpoint", checkpointer.Run, checkpointer.Interrupt)

Expand Down
15 changes: 14 additions & 1 deletion pkg/log/eventlog/eventlog_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"bytes"
"io"
"sync"
"reflect"

"github.com/go-kit/kit/log"
)
Expand All @@ -33,7 +34,19 @@
func (l *eventLogger) Log(keyvals ...interface{}) error {
lb := l.getLoggerBuf()
defer l.putLoggerBuf(lb)
if err := lb.logger.Log(keyvals...); err != nil {

// fmtlogger does not support array, chan, func, slice, struct, or map
// so we'll do any pre-processing for these types here
RebeccaMahany marked this conversation as resolved.
Show resolved Hide resolved
formattedKeyVals := make([]interface{}, len(keyvals))
for idx, val := range keyvals {
switch knownValue := val.(type) {
case reflect.Array, reflect.Chan, reflect.Func, reflect.Map, reflect.Slice, reflect.Struct:
formattedKeyVals[idx] = fmt.Sprintf("%+v", val)
default:
formattedKeyVals[idx] = val
}

if err := lb.logger.Log(formattedKeyVals...); err != nil {
return err
}

Expand All @@ -47,12 +60,12 @@
}

func (l *eventLogger) getLoggerBuf() *loggerBuf {
lb := l.bufPool.Get().(*loggerBuf)

Check failure on line 63 in pkg/log/eventlog/eventlog_windows.go

View workflow job for this annotation

GitHub Actions / launcher (windows-latest)

missing ',' in composite literal

Check failure on line 63 in pkg/log/eventlog/eventlog_windows.go

View workflow job for this annotation

GitHub Actions / launcher (windows-latest)

missing ',' before newline in composite literal
if lb.buf == nil {

Check failure on line 64 in pkg/log/eventlog/eventlog_windows.go

View workflow job for this annotation

GitHub Actions / launcher (windows-latest)

expected operand, found 'if'

Check failure on line 64 in pkg/log/eventlog/eventlog_windows.go

View workflow job for this annotation

GitHub Actions / launcher (windows-latest)

missing ',' in composite literal
lb.buf = &bytes.Buffer{}

Check failure on line 65 in pkg/log/eventlog/eventlog_windows.go

View workflow job for this annotation

GitHub Actions / launcher (windows-latest)

missing ',' in composite literal

Check failure on line 65 in pkg/log/eventlog/eventlog_windows.go

View workflow job for this annotation

GitHub Actions / launcher (windows-latest)

missing ',' before newline in composite literal
lb.logger = log.With(l.newLogger(lb.buf), "caller", log.Caller(4))

Check failure on line 66 in pkg/log/eventlog/eventlog_windows.go

View workflow job for this annotation

GitHub Actions / launcher (windows-latest)

missing ',' in composite literal

Check failure on line 66 in pkg/log/eventlog/eventlog_windows.go

View workflow job for this annotation

GitHub Actions / launcher (windows-latest)

missing ',' before newline in composite literal
} else {

Check failure on line 67 in pkg/log/eventlog/eventlog_windows.go

View workflow job for this annotation

GitHub Actions / launcher (windows-latest)

missing ',' in composite literal
lb.buf.Reset()

Check failure on line 68 in pkg/log/eventlog/eventlog_windows.go

View workflow job for this annotation

GitHub Actions / launcher (windows-latest)

missing ',' before newline in composite literal
}
return lb
}
Expand Down
Loading