tursodatabase/libsql-python

Is there a way to disable sync logs?

Opened this issue · 7 comments

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?

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

This should be fixed by #40 once it is merged

@penberg apparently #40 did not fix it

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

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.

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

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.