libsql-experimental-python icon indicating copy to clipboard operation
libsql-experimental-python copied to clipboard

Is there a way to disable sync logs?

Open juliuslipp opened this issue 1 year ago • 7 comments
trafficstars

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?

juliuslipp avatar Mar 01 '24 13:03 juliuslipp

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

grumpyp avatar Mar 09 '24 07:03 grumpyp

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

penberg avatar Mar 10 '24 15:03 penberg

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

isaccavalcante avatar May 09 '24 02:05 isaccavalcante

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?

hbmartin avatar Jul 09 '24 20:07 hbmartin

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.

FyZyX avatar Jul 14 '24 02:07 FyZyX

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

leonardo-blas avatar Oct 31 '24 06:10 leonardo-blas

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.

gernotstarke avatar Nov 05 '24 12:11 gernotstarke