-
Notifications
You must be signed in to change notification settings - Fork 907
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: use logkitty
to format android logs
#294
Changes from 6 commits
834f702
ea2cb87
74b0be7
1da613f
4e686f8
fb98123
bfa1e1e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,26 +5,31 @@ | |
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import {spawnSync} from 'child_process'; | ||
import { | ||
logkitty, | ||
makeTagsFilter, | ||
formatEntry, | ||
formatError, | ||
Priority, | ||
} from 'logkitty'; | ||
import {logger} from '@react-native-community/cli-tools'; | ||
|
||
/** | ||
* Starts adb logcat | ||
*/ | ||
async function logAndroid() { | ||
const adbPath = process.env.ANDROID_HOME | ||
? `${process.env.ANDROID_HOME}/platform-tools/adb` | ||
: 'adb'; | ||
|
||
const adbArgs = ['logcat', '*:S', 'ReactNative:V', 'ReactNativeJS:V']; | ||
logger.info('Starting logkitty'); | ||
|
||
logger.info(`Starting the logger (${adbPath} ${adbArgs.join(' ')})...`); | ||
const emitter = logkitty({ | ||
platform: 'android', | ||
minPriority: Priority.VERBOSE, | ||
filter: makeTagsFilter('ReactNative', 'ReactNativeJS'), | ||
}); | ||
|
||
const log = spawnSync(adbPath, adbArgs, {stdio: 'inherit'}); | ||
emitter.on('entry', (entry: Entry) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Entry type is not imported but I guess there's no Flow types for this lib There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also does There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As far as I know, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
logger.log(formatEntry(entry)); | ||
}); | ||
|
||
if (log.error !== null) { | ||
throw log.error; | ||
} | ||
emitter.on('error', (error: Error) => { | ||
logger.log(formatError(error)); | ||
}); | ||
} | ||
|
||
export default { | ||
|
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.
Interesting. That means we could possibly support iOS in the future too!