-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Add logs! #17525
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
base: main
Are you sure you want to change the base?
Add logs! #17525
Conversation
Hi there 👋 thanks for taking the time to make this however I am struggling to see what you have changed due to the format of the PR. |
Changes in Detail
LogToFile Function: A new function void LogToFile(const std::string& message) has been implemented. This function: Uses a static std::ofstream logfile("firestore_log.txt", std::ios_base::app); variable to ensure the log file (firestore_log.txt) is opened only once and new entries are appended to the end of the file (std::ios_base::app). Checks if the file is open before attempting to write. Appends the received message to the file, followed by a newline. Currently, the implementation in the diff doesn't include a timestamp, but the includes suggest this functionality might be added in the future or is a preparation for it.
An error log (LogToFile) has been added when a named query is not found, indicating the query's name. A success log (LogToFile) has been added after a successful named query read, indicating the query's name. An error log (LogToFile) has also been added when the query read fails, detailing the reason. TransactionGet: An error log (LogToFile) has been included to record failures in reading documents within transactions, along with the document path and error message. A success log (LogToFile) has been added for successful document reads within transactions. DocumentReferenceGet: Similarly, success and error logs (LogToFile) have been added for document retrieval operations by reference, including the document path and error message. QuerySnapshotStreamHandler and DocumentSnapshotStreamHandler (Listeners): Success and error logs (LogToFile) have been added within the callbacks of snapshot listeners for queries and documents, indicating when there's a data update or a listener failure.
Why These Changes Are Important Easier Diagnosis: With file logging, developers can easily inspect the execution flow and identify issues in read operations (queries and gets) and transactions without needing to attach a debugger. This is crucial for understanding application behavior in production or testing environments where interactive debugging can be difficult. Error Tracking: Detailed success and failure logs, including error messages, help pinpoint the root cause of problems related to Firestore communication, data not found, or permission issues. Future Performance Insights: While the current implementation is basic, the logging infrastructure with timestamps (suggested by the and includes) can be expanded to record the duration of operations, providing insights into performance and bottlenecks. In summary, this commit adds a valuable layer of observability to the plugin, making it more robust and easier to maintain. |
I'm sorry for not explaining! |
Hi @HeroRickyGAMES, could you please run |
The error log was not normally displayed!
However, after analysis and development I came to the conclusion that I need to have the logs to know what happens when it crashes!