{"action":"created","comment":{"url":"https://api.github.com/repos/appium/appium-ios-driver/pulls/comments/36229852","id":36229852,"diff_hunk":"@@ -0,0 +1,203 @@\n+import path from 'path';\n+import _ from 'lodash';\n+import which from 'which';\n+import glob from 'glob';\n+import { fs, getLogger } from 'appium-logger';\n+import mkdirp from 'mkdirp';\n+import touch from 'touch';\n+import xcode from 'xcode'; \n+import { SubProcess } from 'teen_process';\n+\n+// Date-Utils: Polyfills for the Date object\n+\n+let START_TIMEOUT = 10000;\n+let logger = getLogger('IOS-log');\n+\n+class IOSLog { \n+\n+  constructor(opts) {\n+    this.udid = opts.udid;\n+    this.simUdid = opts.simUdid;\n+    this.showLogs = opts.showLogs;\n+    this.proc = null;\n+    this.onIosLogStart = null;\n+    this.iosLogStarted = false;\n+    this.iosLogStartTime = null;\n+    this.loggingModeOn = true;\n+    this.logs = [];\n+    this.logRow = '';\n+    this.logsSinceLastRequest = [];\n+    this.startTimer = null;\n+  }\n+\n+  async startCapture () {\n+    if (this.udid) { \n+      this.loggingModeOn = false;\n+      let spawnEnv = _.clone(process.env);\n+      logger.debug('Attempting iOS device log capture via libimobiledevice idevicesyslog');\n+      let err = await which('idevicesyslog');\n+      if (!err) { \n+        this.proc = new SubProcess('idevicesyslog', {env: spawnEnv});\n+      } else {\n+        logger.warn('Could not capture device log using libimobiledevice idevicesyslog.' +\n+            ' Libimobiledevice probably is not installed');\n+        logger.debug('Attempting iOS device log capture via deviceconsole');\n+        let limDir = path.resolve(__dirname, '../../../build/deviceconsole');\n+        spawnEnv.PATH = `${process.env.PATH}:${limDir}`;\n+        spawnEnv.DYLD_LIBRARY_PATH = `${limDir}:${process.env.DYLD_LIBRARY_PATH}`;\n+        this.proc =  new SubProcess('deviceconsole', ['-u', this.udid], {env: spawnEnv});\n+      }\n+      await this.finishStartingLogCapture();\n+      return;\n+    } \n+\n+    let xcodeVersion = await xcode.getVersion();\n+    let ver = parseInt(xcodeVersion.split('.')[0], 10);\n+\n+    if ( ver < 5 ) {\n+      logger.debug('Starting iOS6.* simulator log capture');\n+      this.proc = new SubProcess('tail', ['-f', '-n', '1', '/var/log/system.log']);\n+      await this.finishStartingLogCapture();\n+      return;\n+    }\n+\n+    let logsPath;\n+\n+    if (ver >= 6) { \n+      logger.debug('Starting iOS 8.*/9.* simulator log capture');\n+        if (_.isUndefined(this.simUdid)) {\n+          logger.errorAndThrow('iOS 8*/9.* log capture requires a sim udid'); \n+        }\n+        logsPath = path.resolve(process.env.HOME, 'Library', 'Logs', 'CoreSimulator', this.simUdid); \n+    } else {\n+        logger.debug('Starting iOS7.* simulator log capture');\n+        logsPath = path.resolve(process.env.HOME, 'Library', 'Logs', 'iOS Simulator', '7.*');\n+    }\n+\n+    try {\n+      if (logsPath.indexOf('*') >= 0) {\n+        return; \n+      }\n+      await mkdirp(logsPath);\n+      await touch(path.resolve(logsPath, 'system.log'));\n+      await fs.appendFile(path.resolve(logsPath, 'system.log'), \n+            'A new Simulator is about to start!'); \n+      let files;\n+      try {\n+        files = await glob(path.resolve(logsPath, 'system.log'));\n+        if (files.length < 1) {\n+          throw 'Could not start log capture';\n+        }\n+      } catch (e) {\n+        logger.error(`Could not start log capture because no iOS ` +\n+        `simulator logs could be found at ${logsPath}/system.log` +","path":"lib/ios-log.js","position":93,"original_position":93,"commit_id":"60216baf958fb8d9b9dc75994ada0ab9a151a9c1","original_commit_id":"651daa3d2d29add577a47691425aabdc6ba83f87","user":{"login":"jlipps","id":605053,"avatar_url":"https://avatars.githubusercontent.com/u/605053?v=3","gravatar_id":"","url":"https://api.github.com/users/jlipps","html_url":"https://github.com/jlipps","followers_url":"https://api.github.com/users/jlipps/followers","following_url":"https://api.github.com/users/jlipps/following{/other_user}","gists_url":"https://api.github.com/users/jlipps/gists{/gist_id}","starred_url":"https://api.github.com/users/jlipps/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jlipps/subscriptions","organizations_url":"https://api.github.com/users/jlipps/orgs","repos_url":"https://api.github.com/users/jlipps/repos","events_url":"https://api.github.com/users/jlipps/events{/privacy}","received_events_url":"https://api.github.com/users/jlipps/received_events","type":"User","site_admin":false},"body":"we line subsequent string lines up under the beginning of the first line's string. does that make sense? kinda hard to explain in words...","created_at":"2015-08-04T19:18:25Z","updated_at":"2015-08-04T19:18:25Z","html_url":"https://github.com/appium/appium-ios-driver/pull/2#discussion_r36229852","pull_request_url":"https://api.github.com/repos/appium/appium-ios-driver/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/appium/appium-ios-driver/pulls/comments/36229852"},"html":{"href":"https://github.com/appium/appium-ios-driver/pull/2#discussion_r36229852"},"pull_request":{"href":"https://api.github.com/repos/appium/appium-ios-driver/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/appium/appium-ios-driver/pulls/2","id":41156135,"html_url":"https://github.com/appium/appium-ios-driver/pull/2","diff_url":"https://github.com/appium/appium-ios-driver/pull/2.diff","patch_url":"https://github.com/appium/appium-ios-driver/pull/2.patch","issue_url":"https://api.github.com/repos/appium/appium-ios-driver/issues/2","number":2,"state":"open","locked":false,"title":"ios-log and ios-crash-log first run through","user":{"login":"syang97","id":8731793,"avatar_url":"https://avatars.githubusercontent.com/u/8731793?v=3","gravatar_id":"","url":"https://api.github.com/users/syang97","html_url":"https://github.com/syang97","followers_url":"https://api.github.com/users/syang97/followers","following_url":"https://api.github.com/users/syang97/following{/other_user}","gists_url":"https://api.github.com/users/syang97/gists{/gist_id}","starred_url":"https://api.github.com/users/syang97/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/syang97/subscriptions","organizations_url":"https://api.github.com/users/syang97/orgs","repos_url":"https://api.github.com/users/syang97/repos","events_url":"https://api.github.com/users/syang97/events{/privacy}","received_events_url":"https://api.github.com/users/syang97/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-07-29T18:32:11Z","updated_at":"2015-08-04T19:18:25Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b9d1940d3b070ebeb1ccb899a2f31c4651e84caa","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/appium/appium-ios-driver/pulls/2/commits","review_comments_url":"https://api.github.com/repos/appium/appium-ios-driver/pulls/2/comments","review_comment_url":"https://api.github.com/repos/appium/appium-ios-driver/pulls/comments{/number}","comments_url":"https://api.github.com/repos/appium/appium-ios-driver/issues/2/comments","statuses_url":"https://api.github.com/repos/appium/appium-ios-driver/statuses/60216baf958fb8d9b9dc75994ada0ab9a151a9c1","head":{"label":"syang97:master","ref":"master","sha":"60216baf958fb8d9b9dc75994ada0ab9a151a9c1","user":{"login":"syang97","id":8731793,"avatar_url":"https://avatars.githubusercontent.com/u/8731793?v=3","gravatar_id":"","url":"https://api.github.com/users/syang97","html_url":"https://github.com/syang97","followers_url":"https://api.github.com/users/syang97/followers","following_url":"https://api.github.com/users/syang97/following{/other_user}","gists_url":"https://api.github.com/users/syang97/gists{/gist_id}","starred_url":"https://api.github.com/users/syang97/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/syang97/subscriptions","organizations_url":"https://api.github.com/users/syang97/orgs","repos_url":"https://api.github.com/users/syang97/repos","events_url":"https://api.github.com/users/syang97/events{/privacy}","received_events_url":"https://api.github.com/users/syang97/received_events","type":"User","site_admin":false},"repo":{"id":39797094,"name":"appium-ios-driver","full_name":"syang97/appium-ios-driver","owner":{"login":"syang97","id":8731793,"avatar_url":"https://avatars.githubusercontent.com/u/8731793?v=3","gravatar_id":"","url":"https://api.github.com/users/syang97","html_url":"https://github.com/syang97","followers_url":"https://api.github.com/users/syang97/followers","following_url":"https://api.github.com/users/syang97/following{/other_user}","gists_url":"https://api.github.com/users/syang97/gists{/gist_id}","starred_url":"https://api.github.com/users/syang97/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/syang97/subscriptions","organizations_url":"https://api.github.com/users/syang97/orgs","repos_url":"https://api.github.com/users/syang97/repos","events_url":"https://api.github.com/users/syang97/events{/privacy}","received_events_url":"https://api.github.com/users/syang97/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/syang97/appium-ios-driver","description":"The iOS driver for the new appium.","fork":true,"url":"https://api.github.com/repos/syang97/appium-ios-driver","forks_url":"https://api.github.com/repos/syang97/appium-ios-driver/forks","keys_url":"https://api.github.com/repos/syang97/appium-ios-driver/keys{/key_id}","collaborators_url":"https://api.github.com/repos/syang97/appium-ios-driver/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/syang97/appium-ios-driver/teams","hooks_url":"https://api.github.com/repos/syang97/appium-ios-driver/hooks","issue_events_url":"https://api.github.com/repos/syang97/appium-ios-driver/issues/events{/number}","events_url":"https://api.github.com/repos/syang97/appium-ios-driver/events","assignees_url":"https://api.github.com/repos/syang97/appium-ios-driver/assignees{/user}","branches_url":"https://api.github.com/repos/syang97/appium-ios-driver/branches{/branch}","tags_url":"https://api.github.com/repos/syang97/appium-ios-driver/tags","blobs_url":"https://api.github.com/repos/syang97/appium-ios-driver/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/syang97/appium-ios-driver/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/syang97/appium-ios-driver/git/refs{/sha}","trees_url":"https://api.github.com/repos/syang97/appium-ios-driver/git/trees{/sha}","statuses_url":"https://api.github.com/repos/syang97/appium-ios-driver/statuses/{sha}","languages_url":"https://api.github.com/repos/syang97/appium-ios-driver/languages","stargazers_url":"https://api.github.com/repos/syang97/appium-ios-driver/stargazers","contributors_url":"https://api.github.com/repos/syang97/appium-ios-driver/contributors","subscribers_url":"https://api.github.com/repos/syang97/appium-ios-driver/subscribers","subscription_url":"https://api.github.com/repos/syang97/appium-ios-driver/subscription","commits_url":"https://api.github.com/repos/syang97/appium-ios-driver/commits{/sha}","git_commits_url":"https://api.github.com/repos/syang97/appium-ios-driver/git/commits{/sha}","comments_url":"https://api.github.com/repos/syang97/appium-ios-driver/comments{/number}","issue_comment_url":"https://api.github.com/repos/syang97/appium-ios-driver/issues/comments{/number}","contents_url":"https://api.github.com/repos/syang97/appium-ios-driver/contents/{+path}","compare_url":"https://api.github.com/repos/syang97/appium-ios-driver/compare/{base}...{head}","merges_url":"https://api.github.com/repos/syang97/appium-ios-driver/merges","archive_url":"https://api.github.com/repos/syang97/appium-ios-driver/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/syang97/appium-ios-driver/downloads","issues_url":"https://api.github.com/repos/syang97/appium-ios-driver/issues{/number}","pulls_url":"https://api.github.com/repos/syang97/appium-ios-driver/pulls{/number}","milestones_url":"https://api.github.com/repos/syang97/appium-ios-driver/milestones{/number}","notifications_url":"https://api.github.com/repos/syang97/appium-ios-driver/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/syang97/appium-ios-driver/labels{/name}","releases_url":"https://api.github.com/repos/syang97/appium-ios-driver/releases{/id}","created_at":"2015-07-27T20:47:57Z","updated_at":"2015-07-27T20:47:57Z","pushed_at":"2015-08-04T19:13:17Z","git_url":"git://github.com/syang97/appium-ios-driver.git","ssh_url":"git@github.com:syang97/appium-ios-driver.git","clone_url":"https://github.com/syang97/appium-ios-driver.git","svn_url":"https://github.com/syang97/appium-ios-driver","homepage":null,"size":92,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"appium:master","ref":"master","sha":"3556c847a8cefb6afd5b6998af4648e2245a674a","user":{"login":"appium","id":3221291,"avatar_url":"https://avatars.githubusercontent.com/u/3221291?v=3","gravatar_id":"","url":"https://api.github.com/users/appium","html_url":"https://github.com/appium","followers_url":"https://api.github.com/users/appium/followers","following_url":"https://api.github.com/users/appium/following{/other_user}","gists_url":"https://api.github.com/users/appium/gists{/gist_id}","starred_url":"https://api.github.com/users/appium/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/appium/subscriptions","organizations_url":"https://api.github.com/users/appium/orgs","repos_url":"https://api.github.com/users/appium/repos","events_url":"https://api.github.com/users/appium/events{/privacy}","received_events_url":"https://api.github.com/users/appium/received_events","type":"Organization","site_admin":false},"repo":{"id":39789366,"name":"appium-ios-driver","full_name":"appium/appium-ios-driver","owner":{"login":"appium","id":3221291,"avatar_url":"https://avatars.githubusercontent.com/u/3221291?v=3","gravatar_id":"","url":"https://api.github.com/users/appium","html_url":"https://github.com/appium","followers_url":"https://api.github.com/users/appium/followers","following_url":"https://api.github.com/users/appium/following{/other_user}","gists_url":"https://api.github.com/users/appium/gists{/gist_id}","starred_url":"https://api.github.com/users/appium/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/appium/subscriptions","organizations_url":"https://api.github.com/users/appium/orgs","repos_url":"https://api.github.com/users/appium/repos","events_url":"https://api.github.com/users/appium/events{/privacy}","received_events_url":"https://api.github.com/users/appium/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/appium/appium-ios-driver","description":"The iOS driver for the new appium.","fork":false,"url":"https://api.github.com/repos/appium/appium-ios-driver","forks_url":"https://api.github.com/repos/appium/appium-ios-driver/forks","keys_url":"https://api.github.com/repos/appium/appium-ios-driver/keys{/key_id}","collaborators_url":"https://api.github.com/repos/appium/appium-ios-driver/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/appium/appium-ios-driver/teams","hooks_url":"https://api.github.com/repos/appium/appium-ios-driver/hooks","issue_events_url":"https://api.github.com/repos/appium/appium-ios-driver/issues/events{/number}","events_url":"https://api.github.com/repos/appium/appium-ios-driver/events","assignees_url":"https://api.github.com/repos/appium/appium-ios-driver/assignees{/user}","branches_url":"https://api.github.com/repos/appium/appium-ios-driver/branches{/branch}","tags_url":"https://api.github.com/repos/appium/appium-ios-driver/tags","blobs_url":"https://api.github.com/repos/appium/appium-ios-driver/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/appium/appium-ios-driver/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/appium/appium-ios-driver/git/refs{/sha}","trees_url":"https://api.github.com/repos/appium/appium-ios-driver/git/trees{/sha}","statuses_url":"https://api.github.com/repos/appium/appium-ios-driver/statuses/{sha}","languages_url":"https://api.github.com/repos/appium/appium-ios-driver/languages","stargazers_url":"https://api.github.com/repos/appium/appium-ios-driver/stargazers","contributors_url":"https://api.github.com/repos/appium/appium-ios-driver/contributors","subscribers_url":"https://api.github.com/repos/appium/appium-ios-driver/subscribers","subscription_url":"https://api.github.com/repos/appium/appium-ios-driver/subscription","commits_url":"https://api.github.com/repos/appium/appium-ios-driver/commits{/sha}","git_commits_url":"https://api.github.com/repos/appium/appium-ios-driver/git/commits{/sha}","comments_url":"https://api.github.com/repos/appium/appium-ios-driver/comments{/number}","issue_comment_url":"https://api.github.com/repos/appium/appium-ios-driver/issues/comments{/number}","contents_url":"https://api.github.com/repos/appium/appium-ios-driver/contents/{+path}","compare_url":"https://api.github.com/repos/appium/appium-ios-driver/compare/{base}...{head}","merges_url":"https://api.github.com/repos/appium/appium-ios-driver/merges","archive_url":"https://api.github.com/repos/appium/appium-ios-driver/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/appium/appium-ios-driver/downloads","issues_url":"https://api.github.com/repos/appium/appium-ios-driver/issues{/number}","pulls_url":"https://api.github.com/repos/appium/appium-ios-driver/pulls{/number}","milestones_url":"https://api.github.com/repos/appium/appium-ios-driver/milestones{/number}","notifications_url":"https://api.github.com/repos/appium/appium-ios-driver/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/appium/appium-ios-driver/labels{/name}","releases_url":"https://api.github.com/repos/appium/appium-ios-driver/releases{/id}","created_at":"2015-07-27T17:54:32Z","updated_at":"2015-07-27T20:13:13Z","pushed_at":"2015-08-04T19:13:17Z","git_url":"git://github.com/appium/appium-ios-driver.git","ssh_url":"git@github.com:appium/appium-ios-driver.git","clone_url":"https://github.com/appium/appium-ios-driver.git","svn_url":"https://github.com/appium/appium-ios-driver","homepage":null,"size":243,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":2,"forks":1,"open_issues":2,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/appium/appium-ios-driver/pulls/2"},"html":{"href":"https://github.com/appium/appium-ios-driver/pull/2"},"issue":{"href":"https://api.github.com/repos/appium/appium-ios-driver/issues/2"},"comments":{"href":"https://api.github.com/repos/appium/appium-ios-driver/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/appium/appium-ios-driver/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/appium/appium-ios-driver/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/appium/appium-ios-driver/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/appium/appium-ios-driver/statuses/60216baf958fb8d9b9dc75994ada0ab9a151a9c1"}}}}