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(ui): logs panel #94

Merged
merged 5 commits into from
Feb 3, 2025
Merged

Conversation

oshcherbakovv
Copy link

No description provided.

@oshcherbakovv oshcherbakovv self-assigned this Jan 29, 2025
@oshcherbakovv oshcherbakovv requested a review from a team as a code owner January 29, 2025 10:32
{ name: 'Fatal', value: LogPriority.FATAL },
]

export const Filter = observer(({ column }: { column: Column<LogcatEntryMessage, unknown> }) => {

Choose a reason for hiding this comment

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

Maybe LogsFilter?


const FILE_EXTENSION_OPTIONS: SelectOption<LogsFileExtension>[] = [
{ name: 'JSON', value: 'json' },
{ name: 'LOG', value: 'log' },

Choose a reason for hiding this comment

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

Is it translatable?
Maybe more human string can be used here like JSON file or Raw lines (.log)

Comment on lines +15 to +21
/* NOTE: Do not mutate this object to ensure stable references for React Table.
For more details, see: https://tanstack.com/table/latest/docs/guide/data#give-data-a-stable-reference
*/

Choose a reason for hiding this comment

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

Judging by the constructor() this comment block should relate only to batchedLogs member

Choose a reason for hiding this comment

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

And if an object should not mutate, maybe use readonly or const?

Copy link
Author

Choose a reason for hiding this comment

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

I can't do this because of that

this.logsByDeviceSerial = {
...this.logsByDeviceSerial,
[serial]: {
...this.logsByDeviceSerial[serial],
logs: [...this.logsByDeviceSerial[serial].logs, ...filteredLogs],
},
}

})

this.onLogcatEntry = this.onLogcatEntry.bind(this)
this.debouncedFlushLogs = debounce(this.flushLogs.bind(this), 100)

Choose a reason for hiding this comment

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

This should be throttle instead of debounce

Copy link
Author

Choose a reason for hiding this comment

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

That's a very good point, I agree

this.debouncedFlushLogs(data.serial)
}

private debouncedFlushLogs: (serial: string) => void

Choose a reason for hiding this comment

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

Why not implement the debouncedFlushLogs here?

Comment on lines 77 to 83
this.logsByDeviceSerial = {
...this.logsByDeviceSerial,
[serial]: {
...this.logsByDeviceSerial[serial],
logs: [...this.logsByDeviceSerial[serial].logs, ...this.batchedLogs],
},
}

Choose a reason for hiding this comment

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

This will very quickly drain the memory for prolonged logcat sessions.
Android devices generate A LOG of logs.
We need to find a way to store them without the copy overhead.
Maybe even implement filters when receiving the log entries so we don't even store the unnecessary logs

Copy link
Author

Choose a reason for hiding this comment

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

There is a limit of 3000 logs per device
I've also implemented filters when receiving the logs

this.setLogcatStarted(serial, false)
}

clearDeviceLogs(serial: string): void {

Choose a reason for hiding this comment

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

This should also be called when we release the device or the device panel is no longer shown/used

Comment on lines +2 to +10
UNKNOWN,
DEFAULT,
VERBOSE,
DEBUG,
INFO,
WARN,
ERROR,
FATAL,
SILENT,

Choose a reason for hiding this comment

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

I think that is the third time I see this enumeration.
It's mostly OK but what if something can be done about it?

@irdkwmnsb irdkwmnsb mentioned this pull request Jan 30, 2025
ui/public/locales/ru-RU/translation.json Show resolved Hide resolved
ui/public/locales/tt-RU/translation.json Outdated Show resolved Hide resolved
Comment on lines +14 to +16
clearTimeout(lastFn)

lastFn = setTimeout(

Choose a reason for hiding this comment

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

Every call to throttle while it's inTrottle will clear the last timeout.

if (!inThrottle) {
fn.apply(this, args)
lastTime = Date.now()
inThrottle = true

Choose a reason for hiding this comment

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

inThrottle is never set to false after it's not in throttle mode

let inThrottle: boolean
let lastFn: ReturnType<typeof setTimeout>

return function func(this: any, ...args: any[]): void {

Choose a reason for hiding this comment

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

I think a better implementation would be as such:

  1. if we don't have a pending timeout - call the function immediately and start a timeout
  2. if we have a timeout - set a flag that the timeout should call the function
  3. after the timeout is reached - call the function if the flag is set

@oshcherbakovv oshcherbakovv force-pushed the o.shcherbakov/logs-panel/QA-16029 branch from 51d3066 to 8c0fccf Compare February 3, 2025 09:18
@oshcherbakovv oshcherbakovv merged commit 868b20e into master Feb 3, 2025
1 check passed
@oshcherbakovv oshcherbakovv deleted the o.shcherbakov/logs-panel/QA-16029 branch February 3, 2025 11:25
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.

3 participants