-
-
Notifications
You must be signed in to change notification settings - Fork 162
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
feat: Add logger override option, use slog
and capture driver as logs
#497
base: main
Are you sure you want to change the base?
feat: Add logger override option, use slog
and capture driver as logs
#497
Conversation
logger = option.Logger | ||
} | ||
|
||
if option.CaptureAllOutputWithLogger { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @GuyGoldenberg, Output is redirected to stderr
of playwrightDriver is already redirected to options.Stderr
in newPipTransport
, and stdout
only contains one-way communication protocol data. Is there a special reason to log the protocol output?options.stdout
and options.stderr.
It is recommended that the caller handle logging itself.
@@ -72,7 +74,7 @@ func (t *pipeTransport) Send(msg map[string]interface{}) error { | |||
if os.Getenv("DEBUGP") != "" { | |||
fmt.Fprint(os.Stdout, "\x1b[32mSEND>\x1b[0m\n") | |||
if err := json.NewEncoder(os.Stdout).Encode(msg); err != nil { | |||
logger.Printf("could not encode json: %v\n", err) | |||
logger.Error("could not encode json", pwlogger.ErrAttr(err)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only for debugging when developing playwright-go. No errors are printed in the new PR. https://github.com/playwright-community/playwright-go/pull/500/files#diff-5982a4ca350449c8a5deba675bc4bc4bb0f1823c45e6c7ba0076cc6b159fef8fR73
This PR introduces 3 new changes:
log
package toslog
logr
but this introduces a new dependency.slog
such asslog-zerolog
slog-logrus
SlogWriter
which captures the output (stdout
andstderr
) from the driver and writes them in the logger with added fields for context (stream and source)