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

Feature request: log to files #405

Open
rocketraman opened this issue Oct 11, 2024 · 4 comments · May be fixed by #406
Open

Feature request: log to files #405

rocketraman opened this issue Oct 11, 2024 · 4 comments · May be fixed by #406

Comments

@rocketraman
Copy link

rocketraman commented Oct 11, 2024

Sometimes it is useful to log on Android and iOS to files, which can easily be zipped up and transferred for remote analysis.

Now that kotlinx-io has been released and supports multiplatform filesystem writes (via okio, and works at least for most platforms including Android and iOS), it would be great if Kermit would leverage this to provide filesystem writing capability out of the box, rather than having users roll their own LogWriters.

For a logging tool, it would be useful also to support automatic roll-overs and deletion of older logs.

@kpgalligan
Copy link
Collaborator

Any thoughts on good models for this with other logging libraries? For mobile, do other logging libraries have default folders to store to and any kind of built-in functionality for wrapping up files? Probably nothing with actually sending them, but I could see returning a file reference to the zip.

It would be easier to essentially replicate an existing library that people seem to use vs writing something entirely new.

@rocketraman
Copy link
Author

My gold standard for this would likely be the Log4j2 RollingFileAppender but that is far more "full-featured" than I would expect from Kermit.

I've implemented something custom locally which takes in a Path and file name prefix as constructor params, as well as a simple configuration that specifies how big each log file can be before it is rolled, and the number of files to keep. I can start a PR with this implementation if that seems interesting.

This simplistic approach seems to be sufficient for my current needs.

@kpgalligan
Copy link
Collaborator

If you have a rough structure in mind, yeah, a PR would be good. I'd probably release this as another module rather than directly in kermit-core, at least to start. It can be focused more on mobile, or at least platforms that would support files easily (not JS).

@rocketraman rocketraman linked a pull request Oct 16, 2024 that will close this issue
@rocketraman
Copy link
Author

@kpgalligan Created PR #406.

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 a pull request may close this issue.

2 participants