Skip to content

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Add logs! #17525

wants to merge 1 commit into from

Conversation

HeroRickyGAMES
Copy link

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!

@MichaelVerdon
Copy link
Contributor

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.

@HeroRickyGAMES
Copy link
Author

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.
Hello, I added a persistent log using txt files so we can debug both in production and in debug!
These methods have been added
LogToFile("ERROR: TransactionGet - Falha na leitura do documento '" + path +
"'. Motivo: " + error_message);
// FIM NOVO
result(FlutterError(error_message));

Changes in Detail

  1. File Logging Inclusion
    New Includes: Necessary includes for time manipulation (, ) and file operations () have been added, which are fundamental for logging.

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.

  1. Addition of Logs for Read Operations (Get)
    NamedQueryGet:

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.

  1. Minor Adjustments
    The lambda for NamedQueryGet and DocumentReferenceGet now explicitly captures the name and path variables respectively for use in the logs.

Why These Changes Are Important
These modifications are a significant enhancement for the debugging and monitoring of the Firestore plugin for Windows.

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.

@HeroRickyGAMES
Copy link
Author

I'm sorry for not explaining!

@SelaseKay
Copy link
Contributor

Hi @HeroRickyGAMES, could you please run melos format-ci and commit the changes? The current formatting is making it difficult to review your updates. Once that's done, I’ll be able to take a proper look.

@SelaseKay SelaseKay added the blocked: customer-response Waiting for customer response, e.g. more information was requested. label Jul 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked: customer-response Waiting for customer response, e.g. more information was requested.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants