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

feat(appium): Improve context logging #20250

Merged
merged 10 commits into from
Jun 18, 2024

Conversation

kkb912002
Copy link
Contributor

Proposed changes

  1. When logging in JSON format, add context information in the "context" field.
    • Use the winston JSON formatter.

with --log-format pretty_json

{
  "context": {
    "session": "3df936f7-3af6-4f83-ba5b-15c3b26188e9"
  },
  "level": "info",
  "message": "[3df936f7][HTTP] <-- POST /session 200 8696 ms - 1428 "
}
  1. Start logging context information from the "Session created with session id:" log.
     [HTTP] --> POST /session
     [AppiumDriver@5422] Calling AppiumDriver.createSession() with args: [
     ...
     [AppiumDriver@5422] AndroidUiautomator2Driver's BaseDriver version is 9.10.3
     [AndroidUiautomator2Driver@447c] Creating session with W3C capabilities: {
     ...
 ->  [0fdc259f][AndroidUiautomator2Driver@447c] Session created with session id: 0fdc259f-2cce-4a29-a317-41f89ace6d3f
     [0fdc259f][ADB] Found 1 'build-tools' folders under
     ...
     [0fdc259f][HTTP] <-- POST /session 200 7920 ms - 1428

with --log-format pretty_json --log-timestamp

{
  "level": "debug",
  "message": "[AndroidUiautomator2Driver@09ef] Creating session with W3C capabilities: {...}",
  "timestamp": "2024-06-13 03:44:33:396"
}
{
  "context": {
    "session": "ab310c65-b09f-4cc3-93aa-384c667d4422"
  },
  "level": "info",
  "message": "[ab310c65][AndroidUiautomator2Driver@09ef] Session created with session id: ab310c65-b09f-4cc3-93aa-384c667d4422",
  "timestamp": "2024-06-13 03:44:33:399"
}

Types of changes

What types of changes does your code introduce to Appium?
Put an x in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update (if none of the other choices apply)

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • I have read the CONTRIBUTING doc
  • I have signed the CLA
  • Lint and unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added the necessary documentation (if appropriate)
  • Any dependent changes have been merged and published in downstream modules

@mykola-mokhnach mykola-mokhnach merged commit f675abc into appium:master Jun 18, 2024
9 checks passed
@mykola-mokhnach
Copy link
Collaborator

Thank you @kkb912002 for the great work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants