Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
148 changes: 19 additions & 129 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ hypersync-client = "1.4.1"
anyhow = "1"
arrow = { version = "57", features = ["ffi"] }
prefix-hex = "0.7"
env_logger = "0.11"
pyo3-log = "0.13"
faster-hex = "0.9"
ruint = "1"
num-bigint = "0.4"
Expand Down
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,19 @@ export ENVIO_API_TOKEN="your-token-here"
python examples/simple_logs_of_event.py
```

## Logging

The Rust core emits its logs through Python's `logging` module, so the usual handlers, formatters and levels apply. Records from the client arrive under the `hypersync_client` logger (HTTP internals arrive under `reqwest`):

```python
import logging

logging.basicConfig(level=logging.INFO)
logging.getLogger("hypersync_client").setLevel(logging.DEBUG)
```

Configure logging before the first client call. Log levels are cached on the Rust side once a record has been emitted, so changes made later may not take effect.

## What you can build

The Python client is a natural fit for data science workflows, analytics pipelines, and any application that needs fast access to blockchain data from Python:
Expand Down
5 changes: 3 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ use types::RateLimitInfo;

#[pymodule]
fn hypersync(m: &Bound<'_, PyModule>) -> PyResult<()> {
// Forward Rust `log` records to Python's `logging` module.
pyo3_log::try_init().ok();

m.add_class::<HypersyncClient>()?;
m.add_class::<Decoder>()?;
m.add_class::<CallDecoder>()?;
Expand All @@ -51,8 +54,6 @@ impl HypersyncClient {
/// Create a new client with given config
#[new]
fn new(config: ClientConfig) -> Result<HypersyncClient> {
env_logger::try_init().ok();

let config = config.try_convert().context("parse config")?;

// Identify this client (and its version) to the server. `hscp` =
Expand Down