Skip to content

feat: tune pino logger ouput compoments#4856

Open
aaltat wants to merge 8 commits intoMarketSquare:mainfrom
aaltat:playwright_log_txt_improvements
Open

feat: tune pino logger ouput compoments#4856
aaltat wants to merge 8 commits intoMarketSquare:mainfrom
aaltat:playwright_log_txt_improvements

Conversation

@aaltat
Copy link
Copy Markdown
Member

@aaltat aaltat commented Apr 28, 2026

Fixes: #4855

Copilot AI review requested due to automatic review settings April 28, 2026 15:53
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adjusts the Node Playwright wrapper’s centralized pino logger output schema to be more structured/consistent and adds unit tests around the expected log fields.

Changes:

  • Remove default pino base fields (e.g., pid/hostname) by setting base: null.
  • Emit level as a string label via a custom level formatter.
  • Add mixin() fields to each log line (seq and a constant component), and add Jest tests asserting the emitted fields.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
node/playwright-wrapper/browser_logger.ts Updates the pino configuration to customize level formatting, omit base fields, and add seq/component mixins.
node/playwright-wrapper/tests/browser_logger.test.ts Adds tests asserting the expected log JSON schema (level/base/mixin/standard fields).

Comment thread node/playwright-wrapper/__tests__/browser_logger.test.ts Outdated
aaltat added 5 commits April 28, 2026 19:16
…Context gRPC

Add a new SetRFContext gRPC call so Robot Framework test and suite identifiers are included in every structured log line emitted by the Node.js wrapper.

After this change every log line produced while a test is running carries test_id, test_name, suite_id, and suite_name fields, making root-cause analysis in CI significantly easier.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves playwright-log.txt machine-readability by tuning the Node-side pino JSON output and propagating Robot Framework (suite/test/keyword) execution context into the Node Playwright wrapper via a new gRPC call.

Changes:

  • Update Node pino logger configuration to emit string level, add seq and component, and drop default pid/hostname.
  • Add SetRFContext gRPC API + Python listener hooks to push suite/test context into Node; add keyword context updates on trace-group open/close.
  • Add unit tests for the new logger configuration and structured gRPC lifecycle logging; simplify inv lint-node execution logic.

Reviewed changes

Copilot reviewed 13 out of 14 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
node/playwright-wrapper/browser_logger.ts Adds pino base:null, string level formatter, seq/component mixin, and RF context helpers.
node/playwright-wrapper/playwright-state.ts Updates RF keyword context on trace-group open/close; adds handler to apply RF suite/test context from gRPC.
protobuf/playwright.proto Introduces Request.RFContext + SetRFContext RPC.
Browser/keywords/playwright_state.py Adds set_rf_context() to call the new gRPC RPC when Playwright is initialized.
Browser/browser.py Sends suite/test context updates on suite/test start/end via set_rf_context.
node/playwright-wrapper/grpc-service.ts Switches gRPC wrapper logging to structured fields; wires the new RF context RPC handler.
node/playwright-wrapper/keyword-decorators.ts Switches decorator logging to structured gRPC lifecycle fields.
node/playwright-wrapper/response-util.ts Replaces console.log error dumping with structured logger error emission.
node/playwright-wrapper/locator-handler.ts Logs custom locator-handler errors with structured metadata.
node/playwright-wrapper/__tests__/browser_logger.test.ts Adds tests validating logger output fields and RF keyword context behavior.
node/playwright-wrapper/__tests__/keyword-decorators.test.ts Adds tests validating structured gRPC lifecycle logging from async_logger.
utest/test_set_rf_context.py Adds Python unit tests for set_rf_context gRPC call behavior.
tasks.py Removes node lint timestamping and always runs node lint/format when invoked.
.gitignore Ignores node/dynamic-test-app/test-app.log.

Comment thread node/playwright-wrapper/keyword-decorators.ts
Comment thread node/playwright-wrapper/grpc-service.ts
Comment thread node/playwright-wrapper/playwright-state.ts Outdated
Comment thread node/playwright-wrapper/playwright-state.ts
Comment thread node/playwright-wrapper/response-util.ts
Copilot AI review requested due to automatic review settings April 28, 2026 20:07
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements the producer-side logging improvements for playwright-log.txt (#4855) by tuning the Node-side pino logger output and propagating Robot Framework execution context (suite/test/keyword) into Node logs via a new gRPC RPC.

Changes:

  • Update Node pino logger to emit string log levels, add deterministic seq, drop default base fields, and include RF context fields via mixin().
  • Add SetRFContext gRPC RPC + Python listener hooks to set/clear suite/test context, and update Node wrapper to apply the context.
  • Add unit tests for the new logger config and structured gRPC lifecycle logging; simplify lint_node task behavior.

Reviewed changes

Copilot reviewed 14 out of 15 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
utest/test_set_rf_context.py Adds Python unit tests for PlaywrightState.set_rf_context behavior.
tasks.py Simplifies lint_node to always run formatting/linting (CI uses check variants).
protobuf/playwright.proto Adds Request.RFContext message and rpc SetRFContext.
node/playwright-wrapper/response-util.ts Replaces console logging in errorResponse with structured pino error logging.
node/playwright-wrapper/playwright-state.ts Updates keyword context on trace group open/close; adds setRFContext handler; logs page errors as structured internal errors.
node/playwright-wrapper/locator-handler.ts Adds structured internal error logging for custom locator handler failures.
node/playwright-wrapper/keyword-decorators.ts Emits structured grpc lifecycle metadata for wrapped keyword methods.
node/playwright-wrapper/grpc-service.ts Emits structured grpc lifecycle metadata; wires the new RF context RPC into the server implementation.
node/playwright-wrapper/browser_logger.ts Introduces createLogger() factory, seq, component, and module-level RF context merged into each line.
node/playwright-wrapper/__tests__/keyword-decorators.test.ts Adds Jest coverage for structured grpc metadata from async_logger.
node/playwright-wrapper/__tests__/browser_logger.test.ts Adds Jest coverage for new pino formatting and RF keyword context mixin behavior.
atest/test/01_Browser_Management/no_playwright_txt_log.robot Adds an acceptance test scenario around “should not be logged” behavior (naming noted in comments).
Browser/keywords/playwright_state.py Adds Python-side set_rf_context() helper to call SetRFContext over gRPC.
Browser/browser.py Calls set_rf_context() on suite/test start/end to keep Node logs annotated with RF context.
.gitignore Ignores node/dynamic-test-app/test-app.log.

Comment thread Browser/browser.py
def _end_suite(self, name, attrs):
self._remove_from_scope_stack(attrs["id"])
self.suite_ids.pop(attrs["id"], None)
self._playwright_state.set_rf_context(suite_id="", suite_name="")
Resource imports.resource

*** Test Cases ***
This should not be logged to file playwright_log.txt
Comment on lines +986 to +990
export async function setRFContext(request: Request_RFContext): Promise<Response_Empty> {
setRFTestContext(request.testId, request.testName);
setRFSuiteContext(request.suiteId, request.suiteName);
return emptyWithLog('RF context updated');
}
closePage = this.wrapping(playwrightState.closePage);
openTraceGroup = this.wrapping(playwrightState.openTraceGroup);
closeTraceGroup = this.wrappingState(playwrightState.closeTraceGroup);
setRfContext = this.wrapping(playwrightState.setRFContext);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

playwright_log.txt improvements.

2 participants