Code shuffle

Summary:
Moved a lot of utility logic in separate files for Android and iOS, to make cleanup in next diffs easier by having a bit smaller files.

Purely a code shuffle, no functional changes

Reviewed By: passy

Differential Revision: D28102399

fbshipit-source-id: 2fd8f6669bdd2804fa8a7e1791c610ae7883eda6
This commit is contained in:
Michel Weststrate
2021-05-04 13:49:11 -07:00
committed by Facebook GitHub Bot
parent c0633652e8
commit 01ea822341
8 changed files with 228 additions and 179 deletions

View File

@@ -45,7 +45,6 @@ export {Idler, Notification} from 'flipper-plugin';
export {Store, MiddlewareAPI, State as ReduxState} from './reducers/index';
export {default as BaseDevice} from './devices/BaseDevice';
export {DeviceLogEntry, LogLevel, DeviceLogListener} from 'flipper-plugin';
export {shouldParseAndroidLog} from './utils/crashReporterUtility';
export {deconstructClientId} from './utils/clientUtils';
export {default as isProduction} from './utils/isProduction';
export {createTablePlugin} from './createTablePlugin';

View File

@@ -1,76 +0,0 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
import {shouldParseAndroidLog} from '../crashReporterUtility.tsx';
import type {DeviceLogEntry, LogLevel} from '../../';
function getAndroidLog(
date: Date,
type: LogLevel,
tag: string,
message: string,
): DeviceLogEntry {
return {date, type, tag, message, app: 'testapp', pid: 0, tid: 0};
}
test('test shouldParseAndroidLog function for type error and tag is AndroidRuntime', () => {
const referenceDate = new Date();
const log: DeviceLogEntry = getAndroidLog(
new Date(referenceDate.getTime() + 10000), //This log arrives 10 secs after the refernce time
'error',
'AndroidRuntime',
'Possible runtime crash',
);
const shouldParseTheLog = shouldParseAndroidLog(log, referenceDate);
expect(shouldParseTheLog).toEqual(true);
});
test('test shouldParseAndroidLog function for type non-error', () => {
const referenceDate = new Date();
const log: DeviceLogEntry = getAndroidLog(
new Date(referenceDate.getTime() + 10000), //This log arrives 10 secs after the refernce time
'debug',
'fb4a.activitymanager',
'Possible debug info in activitymanager',
);
const shouldParseTheLog = shouldParseAndroidLog(log, referenceDate);
expect(shouldParseTheLog).toEqual(false);
});
test('test shouldParseAndroidLog function for the older android log', () => {
const referenceDate = new Date();
const log: DeviceLogEntry = getAndroidLog(
new Date(referenceDate.getTime() - 10000), //This log arrives 10 secs before the refernce time
'error',
'fb4a.activitymanager',
'Possible error info in activitymanager',
);
const shouldParseTheLog = shouldParseAndroidLog(log, referenceDate);
expect(shouldParseTheLog).toEqual(false);
});
test('test shouldParseAndroidLog function for the fatal log', () => {
const referenceDate = new Date();
const log: DeviceLogEntry = getAndroidLog(
new Date(referenceDate.getTime() + 10000), //This log arrives 10 secs after the refernce time
'fatal',
'arbitrary tag',
'Possible error info in activitymanager',
);
const shouldParseTheLog = shouldParseAndroidLog(log, referenceDate);
expect(shouldParseTheLog).toEqual(true);
});
test('test shouldParseAndroidLog function for the error log which does not staisfy our tags check', () => {
const referenceDate = new Date();
const log: DeviceLogEntry = getAndroidLog(
new Date(referenceDate.getTime() + 10000), //This log arrives 10 secs after the refernce time
'error',
'arbitrary tag',
'Possible error info in fb4a',
);
const shouldParseTheLog = shouldParseAndroidLog(log, referenceDate);
expect(shouldParseTheLog).toEqual(false);
});

View File

@@ -1,21 +0,0 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
import {DeviceLogEntry} from 'flipper-plugin';
export function shouldParseAndroidLog(
entry: DeviceLogEntry,
date: Date,
): boolean {
return (
entry.date.getTime() - date.getTime() > 0 && // The log should have arrived after the device has been registered
((entry.type === 'error' && entry.tag === 'AndroidRuntime') ||
entry.type === 'fatal')
);
}