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 to pass logger into Backend or sync_from/sync_to methods #253

Open
jamesharr opened this issue Nov 19, 2023 · 0 comments
Open

Feature to pass logger into Backend or sync_from/sync_to methods #253

jamesharr opened this issue Nov 19, 2023 · 0 comments

Comments

@jamesharr
Copy link
Contributor

jamesharr commented Nov 19, 2023

Environment

  • DiffSync version: 1.9.0

Proposed Functionality

DiffSync currently establishes its own logger method. This feature would allow the user of DiffSync to pass in a structlog logger with some bound context data, or even pass in a structlog-compatible logger to replace the existing logger.

Below, two examples are provided. This feature would not require both be implemented.

Example usage:

First example - pass logger into backend

my_logger = structlog.get_logger().bind(
    triggered_by="[email protected]",
    trace_id=str(uuid.uuid4()),
)

be1 = MyDiffSyncBackend(loggger=my_logger)
be1.load()
...
be1.sync_to(be2)

Second example - pass logger into sync methods

my_logger = structlog.get_logger().bind(
    triggered_by="[email protected]",
    trace_id=str(uuid.uuid4()),
)

be1 = MyDiffSyncBackend()
be1.load()
...
be1.sync_to(be2, logger=my_logger)

Use Case

  • Provide additional context to each log message using structlog's bind.
  • Provide alternate logger to diffsync
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

No branches or pull requests

1 participant