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

Developing Logging Feature for 'BinLogStreamReader' Object Creation Parameters #460

Conversation

chungeun-choi
Copy link
Contributor

@chungeun-choi chungeun-choi commented Aug 31, 2023

Overview

A functionality has been developed to log the parameters provided by the user when creating a BinLogStreamReader object.


This logging feature is implemented to track the input parameters used to create the object, and it is designed to work within the context of a larger package that might be imported and utilized by other programs.
Therefore, specific log configurations, formats, or handling methods have not been implemented. Instead, this feature has been designed to log messages at the INFO level for visibility.

The parameter 'enable_logging' allows you to check the settings of the BinlogStreamReader object. By default, this parameter is set to 'True'. If you want to disable logging, you can simply set its value to 'False'.



  • The log object can be instantiated and utilized as demonstrated in the dump_events.py file as follows
def main():
   log = logging.getLogger()
   log.setLevel(logging.INFO)
   
   stream = BinLogStreamReader(connection_settings=MYSQL_SETTINGS,
                               server_id=3,
                               blocking=True)

   for binlogevent in stream:
       binlogevent.dump()

   stream.close()
  • Result
INFO:root:Set parameter - connection_settings, value - {'host': '127.0.0.1', 'port': 3306, 'user': 'root', 'passwd': '', 'charset': 'utf8'}
INFO:root:blocking is True
INFO:root:allowed_events: [StopEvent, ExecuteLoadQueryEvent, TableMapEvent, FormatDescriptionEvent, BeginLoadQueryEvent, UpdateRowsEvent, QueryEvent, XAPrepareEvent, DeleteRowsEvent, WriteRowsEvent, RotateEvent, MariadbGtidEvent, HeartbeatLogEvent, GtidEvent, XidEvent]
INFO:root:allowed_events_in_packet: [StopEvent, FormatDescriptionEvent, XAPrepareEvent, RotateEvent, MariadbGtidEvent, GtidEvent, ExecuteLoadQueryEvent, TableMapEvent, BeginLoadQueryEvent, UpdateRowsEvent, QueryEvent, DeleteRowsEvent, WriteRowsEvent, HeartbeatLogEvent, XidEvent]

Benefits

This functionality provides a clear visibility into "What parameters did the user provide when creating a 'BinLogStreamReader' object?" The logging messages help users understand the configuration and input parameters utilized during the object creation process.

@chungeun-choi
Copy link
Contributor Author

i solved the conflicts, and fix typo error!

@julien-duponchelle
Copy link
Owner

Sorry can you rebase your change agaisnt the last main ?

@chungeun-choi
Copy link
Contributor Author

chungeun-choi commented Sep 4, 2023

I merged the contents into the main branch!
In addition, the name of the logging parameter was changed , and the details could be checked through annotation

  • Name of parameter : parma_logging -> enable_logging
  • Add anotations in BinLogStreamReader

@why-arong
Copy link
Contributor

Before the change, we only considered this parameter as a means to monitor how 'BinLogStreamReader' is configured. However, we felt that there may be additional items to log in this project, so we renamed it to enable_logging. For example, the following log entries could be included:

ERROR

In cases where it fails to pass the CRC check.

WARN

When the time of event creation differs from the time of table structure retrieval, leading to incorrect mapping.
Related code

@julien-duponchelle
Copy link
Owner

Good ! I will solve the conflict and merge

@chungeun-choi
Copy link
Contributor Author

@julien-duponchelle I solved confilct and all checks have passed :)

@julien-duponchelle
Copy link
Owner

Hmm seem the conflict solve introduce a problem we have lost the changelog of the new version. I'm going to look at that

@julien-duponchelle
Copy link
Owner

Great you fixed it ! So fast

@chungeun-choi
Copy link
Contributor Author

oh...I'm sorry that I added this part without it. I fixed it!

@julien-duponchelle julien-duponchelle merged commit a097cf0 into julien-duponchelle:main Sep 12, 2023
4 checks passed
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.

3 participants