Enhance logging and add policy test client
- Refactored logOutput function to trace-log stdout and stderr lines for better debugging. - Introduced a new policy test client in cmd/policytest/main.go to publish events and check policy responses. - Added a script to run the policy test, ensuring proper cleanup and error handling. - Updated policy event processing to ensure newline-terminated JSON for compatibility with shell-readers.
This commit is contained in:
@@ -472,12 +472,28 @@ func (sm *SprocketManager) logOutput(stdout, stderr io.ReadCloser) {
|
||||
defer stdout.Close()
|
||||
defer stderr.Close()
|
||||
|
||||
// Trace-log stdout lines
|
||||
go func() {
|
||||
io.Copy(os.Stdout, stdout)
|
||||
scanner := bufio.NewScanner(stdout)
|
||||
for scanner.Scan() {
|
||||
line := scanner.Text()
|
||||
if line == "" {
|
||||
continue
|
||||
}
|
||||
log.T.F("sprocket stdout: %s", line)
|
||||
}
|
||||
}()
|
||||
|
||||
// Trace-log stderr lines
|
||||
go func() {
|
||||
io.Copy(os.Stderr, stderr)
|
||||
scanner := bufio.NewScanner(stderr)
|
||||
for scanner.Scan() {
|
||||
line := scanner.Text()
|
||||
if line == "" {
|
||||
continue
|
||||
}
|
||||
log.T.F("sprocket stderr: %s", line)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user