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

App lifecycle logging & log persistence #286

Merged
merged 74 commits into from
Jan 4, 2024
Merged

Conversation

KennyHuRadar
Copy link
Contributor

@KennyHuRadar KennyHuRadar commented Nov 30, 2023

This PR intends to replace the purely in-memory log buffer with a persistent buffer on disk.

  • RadarFileClass is as simple wrapper for file I/O operations, it can delete files, read files, replace or append data in files.
  • RadarLog is extended to be serialized into string JSONs and back.
  • RadarLogger is extended to append time and battery information behind some logs.
  • RadarLogBuffer is modified and extended to write new logs a in memory buffer that is flushed into disk periodically and when the app is backgrounded. The logs on disk are then read and flushed to the dashboard, similar to the old memory buffer. We also allow for quick appending of logs which is needed when IOS limits the time and resources the SDK has (when backgrounding and terminating the app).

QA:
Unit tests are included for RadarFileClass and RadarLogBuffer
Waypoint build: https://expo.dev/accounts/radarlabs/projects/waypoint/builds/168fb1ba-3517-4036-9fff-811e23f77a37
was able to flush logs as expected to dashboard:
image

@KennyHuRadar KennyHuRadar changed the title Presistent logging Persistent logging Nov 30, 2023
@KennyHuRadar KennyHuRadar marked this pull request as ready for review December 4, 2023 20:53
RadarSDK/Radar.m Outdated Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

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

think RadarFileStorage is probably better naming than RadarFileSystem

@KennyHuRadar
Copy link
Contributor Author

KennyHuRadar commented Dec 20, 2023

@KennyHuRadar
Copy link
Contributor Author

}
}

//for use in testing
Copy link
Contributor

Choose a reason for hiding this comment

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

Comments describing functions follow the format:


/**
 * Return copy of replays in buffer
 */

Copy link
Contributor

@lmeier lmeier left a comment

Choose a reason for hiding this comment

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

lgtm! let's sync with @tjulien during mobile meeting before shipping

also needs rebase & version bump

[self write:level type:type message:message forcePersist:NO];
}

- (void)write:(RadarLogLevel)level type:(RadarLogType)type message:(NSString *)message forcePersist:(BOOL)forcePersist{
Copy link
Contributor

Choose a reason for hiding this comment

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

need space before {

[self writeToFileStorage:flushableLogs];
[self purgeOldestLogs];
[inMemoryLogBuffer removeAllObjects];
if([inMemoryLogBuffer count] > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

spacing between if and (

@KennyHuRadar
Copy link
Contributor Author

@KennyHuRadar
Copy link
Contributor Author

KennyHuRadar commented Jan 3, 2024

https://expo.dev/accounts/radarlabs/projects/waypoint/builds/674c5efa-1ff1-4de9-beb1-61622404631e

In addition to the change of names, we have also decided to not have expose the logging methods via RN, this waypoint build reflects that.

@KennyHuRadar
Copy link
Contributor Author

@KennyHuRadar
Copy link
Contributor Author

Copy link
Contributor

@lmeier lmeier left a comment

Choose a reason for hiding this comment

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

well done, let's ship 🚢 💯

@KennyHuRadar KennyHuRadar merged commit 0864163 into master Jan 4, 2024
2 checks passed
@KennyHuRadar KennyHuRadar deleted the presistent-logging branch January 4, 2024 20:40
ShiCheng-Lu pushed a commit that referenced this pull request Jun 13, 2024
* comment out opened_app

* change numbering on migration guides
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.

2 participants