Module logging

Source
Expand description

Logging and debugging utilities Logging and debugging utilities for the hyperliquid-backtester crate.

This module provides convenient functions for setting up structured logging and debugging support throughout the library.

§Basic Usage

use hyperliquid_backtest::logging::init_logger;

// Initialize with default settings (INFO level)
init_logger();

// Or with custom log level
init_logger_with_level("debug");

§Environment Variables

You can control logging behavior using environment variables:

  • RUST_LOG: Set log level (e.g., debug, info, warn, error)
  • HYPERLIQUID_LOG_FORMAT: Set format (json or pretty)
  • HYPERLIQUID_LOG_FILE: Write logs to file instead of stdout

§Examples

# Enable debug logging
RUST_LOG=debug cargo run --example basic_backtest

# Use JSON format for structured logging
RUST_LOG=info HYPERLIQUID_LOG_FORMAT=json cargo run

# Write logs to file
RUST_LOG=info HYPERLIQUID_LOG_FILE=backtest.log cargo run

Functions§

init_logger
Initialize the default logger with INFO level logging.
init_logger_with_level
Initialize the logger with a specific log level.
init_test_logger
Initialize logger for testing with reduced verbosity.
performance_span
Create a tracing span for performance monitoring.