Comments (4)
Yes the problem is that, unlike RNFS, Expo Fs does not expose the 'appendFile' method. So, for every log, i need to read the contents of the file and write it in full, this obviously causes the problem you described.
There are two ways to fix it:
-
make the procedure synchronous (but this would cause a lot of performance problems)
-
Rewrite the module to work with a queue, string all write requests, and execute them one at a time.
This last option, however, requires a lot of work, I hope they will soon add to expo fs a potion to add lines to a file ...
in the coming weeks I will consider what to do.
from react-native-logs.
@alessandro-bottamedi Yeah, it's a tough one.
I looked a little into RNFS and they have this "append to file" implemented in native code. What about we open a feature request with Expo to add this option? Seems like the code already exists from RNFS so perhaps it's not so much work for Expo to add this option.
Otherwise, I also considered the queue option, and that seems like it adds a lot of complexity. I considered adding it in our logs, because then I could also delay sending logs until we'd initialised our logging settings. That would let me store log levels on the filesystem in the phone for example. But, it's complicated and has the potential to introduce horrible, hard to trace bugs.
One thing to note, I've used a few async / Promise queues, and there are some battle tested libraries out there. Maybe using an existing queue library would be achievable without introducing so much extra code into this package, but adding extra dependencies (which bring their own complications of course).
Anyway, thanks for the considered response. I'll be curious to hear what you think makes sense here.
from react-native-logs.
@chmac @alessandro-bottamedi Hello, please tell me how you solved this problem
from react-native-logs.
@chmac With v 3.0.4 i think I was able to create a custom queue for the ExpoFS module to avoid race conditions issues. I could not use existing queue management packages since they all make use of a DB (sql or realm) and are not compatible with expo.
Please try it and let me know if there are any problems.
from react-native-logs.
Related Issues (20)
- Bug: function type log arguments are printed as `null` HOT 3
- Disable not working HOT 2
- Type errors with noUncheckedIndexedAccess HOT 2
- extensionColors not working on zsh macOS terminal HOT 1
- In transportOptions I'm Not able generate logs.txt file HOT 7
- I'm not able to generate and save(see) log in file manager (storage) of mobile device HOT 1
- how we can access log.txt file in iOS device HOT 5
- Queue? HOT 1
- Open to adding custom formatting support? HOT 2
- Sentry transporter seems to log always to error despite using info/debug.. HOT 2
- Is it possible to store file in Zip(compressed log.txt file) with in cache directory HOT 1
- NSMallocException - Expo device build fatal crash with FileAsyncTransport HOT 1
- Is there a way to pass types to transport function props? HOT 1
- today date formatting is incorrectly described in the docs HOT 1
- Logging to a log level with undefined transport causes app to crash HOT 2
- Using react-native-logs in a regular 'react' web app? HOT 2
- Date format with using {date-today} HOT 1
- use withScope to sentry's message logging?
- Logs cluttered with unformatted component trees
- Logs are not showing color on metro bundler for React native
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-logs.