Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
03c1ab1
feat(zaino-common): add centralized logging infrastructure
nachog00 Feb 19, 2026
c4f4726
refactor(zainod): use centralized logging from zaino-common
nachog00 Feb 19, 2026
dc78a8b
refactor(zaino-testutils): use centralized logging from zaino-common
nachog00 Feb 19, 2026
b38f068
fix(zaino-common): improve default logging config
nachog00 Feb 19, 2026
84e29bc
refactor(zaino-state): truncate hash Display to 8 chars
nachog00 Feb 19, 2026
1f3fcc6
refactor(zaino-common): compact timestamps and enable color by default
nachog00 Feb 19, 2026
67fd7c5
refactor(zaino-common): use pretty format for stream logger
nachog00 Feb 20, 2026
c6b6a10
refactor: use structured tracing fields in log statements
nachog00 Feb 20, 2026
f1c3ecc
refactor(zaino-common): improve tree logger formatting
nachog00 Feb 20, 2026
b254ee0
feat(zaino-state): add tracing instrumentation to key functions
nachog00 Feb 20, 2026
19aa7f5
feat(zaino-common): add Display impl for Network
nachog00 Feb 20, 2026
91965bc
refactor(logging): improve tracing-tree output
nachog00 Feb 20, 2026
b06cca7
feat(zaino-state): add NamedAtomicStatus for status observability
nachog00 Feb 20, 2026
6977843
refactor: use NamedAtomicStatus across components
nachog00 Feb 20, 2026
9580c81
refactor: use Display format for network in tracing spans
nachog00 Feb 20, 2026
5281c05
feat(testutils): add tracing instrumentation to TestManager
nachog00 Feb 20, 2026
d7d748d
build: pass RUST_LOG and ZAINO_LOG_FORMAT to container tests
nachog00 Feb 20, 2026
7465cd9
Merge branch 'dev' into feature/improved-logging
nachog00 Feb 26, 2026
fa70c96
doc(logging): added documentation for logging
nachog00 Feb 26, 2026
9fc4b24
fix: remove duplicate logging init and rename env vars to ZAINOLOG_*
nachog00 Feb 26, 2026
652434c
fix(logging): include zainodlib in default log filter
nachog00 Feb 26, 2026
5214362
fix(tests): use encode_hex instead of Display for TransactionHash
nachog00 Mar 2, 2026
06bcde8
Merge branch 'dev' into feature/improved-logging
nachog00 Mar 2, 2026
6def7da
fix(tests): use encode_hex instead of Display for TransactionHash
nachog00 Mar 2, 2026
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
54 changes: 53 additions & 1 deletion Cargo.lock

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

5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,13 @@ tracing-subscriber = { version = "0.3.20", features = [
"fmt",
"env-filter",
"time",
"json",
] }
tracing-futures = "0.2"
tracing-tree = "0.4"
nu-ansi-term = "0.50"
atty = "0.2"
time = { version = "0.3", features = ["macros", "formatting"] }

# Network / RPC
http = "1.1"
Expand Down
2 changes: 2 additions & 0 deletions Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,8 @@ docker run --rm \
-e "TEST_BINARIES_DIR=${TEST_BINARIES_DIR}" \
-e "NEXTEST_EXPERIMENTAL_LIBTEST_JSON=1" \
-e "CARGO_TARGET_DIR=/home/container_user/zaino/target" \
-e "ZAINOLOG_FORMAT=${ZAINOLOG_FORMAT:-stream}" \
-e "RUST_LOG=${RUST_LOG:-}" \
-w /home/container_user/zaino \
-u container_user \
"${IMAGE_NAME}:$TAG" \
Expand Down
90 changes: 90 additions & 0 deletions docs/logging.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# Logging Configuration

Zaino provides flexible logging with three output formats and configurable verbosity levels.

## Environment Variables

| Variable | Values | Default | Description |
|----------|--------|---------|-------------|
| `RUST_LOG` | Filter string | `zaino=info,zainod=info` | Log level filter |
| `ZAINOLOG_FORMAT` | `stream`, `tree`, `json` | `stream` | Output format |
| `ZAINOLOG_COLOR` | `true`, `false`, `auto` | `true` | ANSI color output |

## Log Formats

### Stream (default)
Flat chronological output with timestamps. Best for general use and piping to files.
```
14:32:01.234 INFO zaino_state::indexer: Starting indexer
14:32:01.456 INFO zaino_state::indexer: Connected to validator
```

### Tree
Hierarchical span-based output showing call structure. Best for debugging complex flows.
```
indexer
├─ INFO Starting indexer
└─ validator_connection
└─ INFO Connected to validator
```

### JSON
Machine-parseable output. Best for log aggregation systems (ELK, Loki, etc).
```json
{"timestamp":"2024-01-15T14:32:01.234Z","level":"INFO","target":"zaino_state::indexer","message":"Starting indexer"}
```

## Usage Examples

### Local Development

```bash
# Default logging (stream format, zaino crates only at INFO level)
zainod start

# Tree format for debugging span hierarchies
ZAINOLOG_FORMAT=tree zainod start

# Debug level for zaino crates
RUST_LOG=zaino=debug,zainod=debug zainod start

# Include zebra logs
RUST_LOG=info zainod start

# Fine-grained control
RUST_LOG="zaino_state=debug,zaino_serve=info,zebra_state=warn" zainod start

# Disable colors (for file output)
ZAINOLOG_COLOR=false zainod start 2>&1 | tee zainod.log
```

### Makefile / Container Tests

The test environment passes logging variables through to containers:

```bash
# Default (stream format)
makers container-test

# Tree format in tests
ZAINOLOG_FORMAT=tree makers container-test

# Debug logging in tests
RUST_LOG=debug ZAINOLOG_FORMAT=tree makers container-test

# JSON output for parsing test logs
ZAINOLOG_FORMAT=json makers container-test 2>&1 | jq .
```

### Production

```bash
# JSON for log aggregation
ZAINOLOG_FORMAT=json ZAINOLOG_COLOR=false zainod start

# Structured logging to file
ZAINOLOG_FORMAT=json ZAINOLOG_COLOR=false zainod start 2>> /var/log/zainod.json

# Minimal logging
RUST_LOG=warn zainod start
```
9 changes: 9 additions & 0 deletions zaino-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,12 @@ serde = { workspace = true, features = ["derive"] }
# Error handling
thiserror = { workspace = true }

# Logging
tracing = { workspace = true }
tracing-subscriber = { workspace = true }
tracing-tree = { workspace = true }
nu-ansi-term = { workspace = true }
atty = { workspace = true }
hex = { workspace = true }
time = { workspace = true }

12 changes: 12 additions & 0 deletions zaino-common/src/config/network.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//! Network type for Zaino configuration.

use std::fmt;

use serde::{Deserialize, Serialize};
use zebra_chain::parameters::testnet::ConfiguredActivationHeights;

Expand Down Expand Up @@ -28,6 +30,16 @@ pub enum Network {
Regtest(ActivationHeights),
}

impl fmt::Display for Network {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Network::Mainnet => write!(f, "Mainnet"),
Network::Testnet => write!(f, "Testnet"),
Network::Regtest(_) => write!(f, "Regtest"),
}
}
}

/// Helper type for Network serialization/deserialization.
///
/// This allows Network to serialize as simple strings ("Mainnet", "Testnet", "Regtest")
Expand Down
1 change: 1 addition & 0 deletions zaino-common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
//! and common utilities used across the Zaino blockchain indexer ecosystem.

pub mod config;
pub mod logging;
pub mod net;
pub mod probing;
pub mod status;
Expand Down
Loading
Loading