tursodatabase / libsql-experimental-python

libSQL API for Python (experimental)
96 stars 10 forks source link

Is there a way to disable sync logs? #39

Open juliuslipp opened 8 months ago

juliuslipp commented 8 months ago

Currently, every time the embedded replica is called it emits some logs:

2024-03-01T12:59:25.195724Z  INFO libsql_replication::replicator: Attempting to perform handshake with primary.
2024-03-01T12:59:25.195778Z  INFO libsql::replication::remote_client: Attempting to perform handshake with primary.
2024-03-01T12:59:25.238512Z  INFO libsql_replication::replicator: Attempting to perform handshake with primary.

Is there a way to disable this?

grumpyp commented 8 months ago

did you try

import logging
replication_logger = logging.getLogger("libsql_replication")
remote_client_logger = logging.getLogger("libsql.replication.remote_client")
# set the logger for liqsql_replication and remote client to WARNING only
replication_logger.setLevel(logging.WARNING)
remote_client_logger.setLevel(logging.WARNING)

Or you could try logging.getLogger().setLevel(logging.WARNING) which sets all loggers to WARNING only

penberg commented 8 months ago

This should be fixed by https://github.com/tursodatabase/libsql-experimental-python/pull/40 once it is merged

isaccavalcante commented 6 months ago

@penberg apparently https://github.com/tursodatabase/libsql-experimental-python/pull/40/ did not fix it

hbmartin commented 4 months ago

Same, I'm on the latest release and tried the config block from @grumpyp but still seeing the logs

Aside, I have a small (<5MB) database with no writes since last sync but calling sync still takes just under a minute, is this expected?

FyZyX commented 3 months ago

Just playing around with this library for the first time today and ran into this. I'm working on a CLI tool and these logs are very distracting. Best solution I found for now is to set the RUST_LOG environment variable to something above info.

export RUST_LOG=error

Python logging configuration won't help here because the logs are coming from the libsql Rust code. You can see the source of the logs here.

Not sure what the optimal solution would be for this library, but I'd probably look for a way to pass the Python log level down to the Rust logging configuration.

Regardless, setting the log level manually should be a sufficient workaround for now.

leonardo-blas commented 1 week ago

Did anyone figure out a way to elegantly manage the log levels?

gernotstarke commented 2 days ago

that behaviour makes using libsql (especially for remote databases) really difficult to use or showcase, as it distracts from regular output. Please make it either configurable or less verbose.