Skip to content

Conversation

@KazuCocoa
Copy link
Member

@KazuCocoa KazuCocoa commented Feb 22, 2019

appium/appium#12203 (comment)

cc @jumois

I ensured below:

@@driver.logs.get :syslog # worked if `skipLogCapture` is false or undefined
@@driver.logs.get :syslog # raised an error if `skipLogCapture` is true <= expected error

showIOSLog appears on appium console at the same time

Copy link
Contributor

@mykola-mokhnach mykola-mokhnach left a comment

Choose a reason for hiding this comment

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

It is not so easy with iOS. Please check all getLog occurrences in the code, because this will most likely throw an error if called with logging disabled. Also, it is necessary to check how such change would influence Simulator startup, because previously the fact that Simulator has started was checked via logs scanning. Which means that Simulator startup is going to always throw an error if the capability is set to true

@KazuCocoa
Copy link
Member Author

Okay. thanks. Will check getLog and related things.


quick look:

Simulator launched as below from no-simulator process.

[XCUITest] Not scrubbing third party app in anticipation of uninstall
[debug] [BaseDriver] Event 'resetComplete' logged at 1550834491026 (20:21:31 GMT+0900 (Japan Standard Time))
[XCUITest] 'skipLogCapture' is set. Skipping starting logs such as crash, system, safari console and safari network.
[XCUITest] Setting up simulator
[debug] [iOSSim] Checking whether simulator has been run before: yes
[debug] [iOSSim] Updating reduce motion. Setting to true.
[debug] [iOS] No reason to set locale
[debug] [iOS] No iOS / app preferences to set
[debug] [iOSSim] Setting preferences of 8CB5BE32-3600-4007-B894-13E48EFB4D65 Simulator to {"ConnectHardwareKeyboard":false}
[debug] [iOSSim] Setting common Simulator preferences to {"RotateWindowWhenSignaledByGuest":true,"ConnectHardwareKeyboard":false}
[debug] [iOSSim] Updated 8CB5BE32-3600-4007-B894-13E48EFB4D65 Simulator preferences at '/Users/kazu/Library/Preferences/com.apple.iphonesimulator.plist' with {"DevicePreferences":{"8CB5BE32-3600-4007-B894-13E48EFB4D65":{"ConnectHardwareKeyboard":false}},"RotateWindowWhenSignaledByGuest":true,"ConnectHardwareKeyboard":false}
[iOSSim] Booting Simulator with UDID 8CB5BE32-3600-4007-B894-13E48EFB4D65...
[iOSSim] Starting Simulator UI with command: open -Fn /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app --args -CurrentDeviceUDID 8CB5BE32-3600-4007-B894-13E48EFB4D65 -ConnectHardwareKeyboard 0
[iOSSim] Simulator with UDID 8CB5BE32-3600-4007-B894-13E48EFB4D65 booted in 6 seconds
[debug] [BaseDriver] Event 'simStarted' logged at 1550834497933 (20:21:37 GMT+0900 (Japan Standard Time))
[XCUITest] 'skipLogCapture' is set. Skipping starting logs such as crash, system, safari console and safari network.
[debug] [XCUITest] Verifying application platform
[debug] [XCUITest] CFBundleSupportedPlatforms: ["iPhoneSimulator"]
[debug] [XCUITest] Reset requested. Removing app with id 'com.example.apple-samplecode.UICatalog' from the device
[debug] [XCUITest] Installing '/var/folders/34/2222sh8n27d6rcp7jqlkw8km0000gn/T/2019122-93066-17uvsy1.yppf/UICatalog.app' on Simulator with UUID '8CB5BE32-3600-4007-B894-13E48EFB4D65'...

@jumois
Copy link

jumois commented Feb 22, 2019

There's also getAllLogs.

Are they used? I didn't find any usages for them.

@KazuCocoa
Copy link
Member Author

KazuCocoa commented Feb 22, 2019

$ cd appium-ios-simulator/
$ git grep "getLogs"

$ cd appium-ios-driver/
$ git grep "getLogs"
lib/commands/logging.js:  const logs = logObject ? await logObject.getLogs() : null;
lib/device-log/ios-crash-log.js:  async getLogs () {
lib/device-log/ios-log.js:  async getLogs () { // eslint-disable-line require-await
lib/device-log/ios-performance-log.js:  async getLogs () { // eslint-disable-line require-await
lib/device-log/ios-performance-log.js:    return this.getLogs();
test/unit/ios-crash-log-specs.js:    (await log.getLogs()).should.have.length(0);
test/unit/ios-crash-log-specs.js:    let end = await log.getLogs();
test/unit/ios-crash-log-specs.js:    let middle = await log.getLogs();
test/unit/ios-crash-log-specs.js:    let end = await log.getLogs();
test/unit/ios-log-specs.js:    let recentLogs = await log.getLogs();
test/unit/ios-log-specs.js:        recentLogs = await log.getLogs();
test/unit/ios-performance-log-specs.js:    (await log.getLogs()).should.eql([message]);
test/unit/ios-performance-log-specs.js:    (await log.getLogs()).should.eql([message]);
test/unit/ios-performance-log-specs.js:    (await log.getLogs()).should.eql([]);

$ cd ../appium-xcuitest-driver/
$ git grep "getLogs"
lib/device-log/rotating-log.js:  async getLogs () { // eslint-disable-line require-await
lib/device-log/safari-network-log.js:  async getLogs () {
lib/device-log/safari-network-log.js:    const logs = await super.getLogs();
$ git grep "getAllLogs"
lib/device-log/rotating-log.js:  async getAllLogs () { // eslint-disable-line require-await

$ cd appium-ios-driver/
$ git grep "getAllLogs"
lib/device-log/ios-crash-log.js:  async getAllLogs () {
lib/device-log/ios-log.js:  async getAllLogs () { // eslint-disable-line require-await
lib/device-log/ios-performance-log.js:  async getAllLogs () { // eslint-disable-line require-await

$ cd ../appium-ios-simulator/
$ git grep "getAllLogs"
$

@KazuCocoa
Copy link
Member Author

I grepped with some wordings and took a look at them.
I also ran some commands, but nothing wrong happened, so far.
(simulator)

@imurchie
Copy link
Contributor

I don't think simulator startup should be a problem. Logs were only used for pre-iOS 8, and even then it uses tail in a separate process (distinct from capturing the logs in the downstream drivers).

screenshotQuality: {
isNumber: true
},
skipLogCapture: {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not necessary if the desired capability is specified in appium-ios-driver.

Copy link
Member Author

@KazuCocoa KazuCocoa Feb 23, 2019

Choose a reason for hiding this comment

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

Will remove here after appium-boneyard/appium-ios-driver#355 and publish new version.
(In this PR or as another PR)

lib/driver.js Outdated
const isLogCaptureStarted = await startLogCapture();

if (this.opts.skipLogCapture) {
log.info("'skipLogCapture' is set. Skipping starting logs such as crash, system, safari console and safari network.");
Copy link
Contributor

Choose a reason for hiding this comment

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

This log line is repeated twice. Perhaps it would be better to move the check into the startLogCapture function on line 337?

const startLogCapture = async () => {
  if (this.opts.skipLogCapture) {
    log.info("'skipLogCapture' is set. Skipping starting logs such as crash, system, safari console and safari network.");
    return false;
  }

  const result = await this.startLogCapture();
  if (result) {
    this.logEvent('logCaptureStarted');
  }
  return result;
};

Copy link
Member Author

Choose a reason for hiding this comment

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

make sense than mine 👍

@mykola-mokhnach
Copy link
Contributor

mykola-mokhnach commented Feb 22, 2019

extensions.setContext will throw an error if this.logs in undefined. It probably makes sense to set this var to an empty object in the driver constructor

lib/driver.js Outdated

await this.runReset();

const memoizedSkipLogCaptureLog = _.memoize(function () {
Copy link
Contributor

Choose a reason for hiding this comment

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

memoizedLogInfo

@mykola-mokhnach
Copy link
Contributor

Please add the new capability into readme

@KazuCocoa KazuCocoa merged commit 6d39998 into appium:master Feb 27, 2019
@KazuCocoa KazuCocoa deleted the add-skip-capture-log branch February 27, 2019 14:27
khanayan123 pushed a commit to khanayan123/appium-xcuitest-driver that referenced this pull request May 10, 2021
* add skipLogCapture

* fix reviews

* use memoize to prevent duplicated log

* append skipLogCapture in caps table, tweak method name
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.

4 participants