1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
//! # Utils Module
//!
//! The `utils` module provides utility functions and structures that support the core functionality
//! of the tastytrade library. It simplifies common tasks and provides essential infrastructure
//! for application configuration and logging.
//!
//! ## Overview
//!
//! This module contains several components that handle configuration management and logging:
//!
//! - **Configuration Management**: Handles application settings including API credentials,
//! environment selection (demo/production), and logging preferences.
//! - **Logging System**: Provides a robust logging infrastructure with configurable log levels
//! and safe initialization logic.
//!
//! ## Submodules
//!
//! ### Config (`config`)
//!
//! The `config` module manages the application's configuration settings, providing methods to:
//!
//! - Load configuration from environment variables
//! - Read/write configuration from JSON files
//! - Validate credentials
//! - Create TastyTrade client instances with the appropriate settings
//!
//! Configuration options include:
//! - API credentials (username and password)
//! - Environment selection (demo/production)
//! - Log level configuration
//! - Session management settings
//!
//! **Example:**
//! ```rust,no_run
//! use tastytrade::utils::config::TastyTradeConfig;
//!
//! // Initialize configuration from environment variables
//! let config = TastyTradeConfig::from_env();
//!
//! // Create a TastyTrade client
//! let tasty = config.create_client();
//! ```
//!
//! ### Logger (`logger`)
//!
//! The `logger` module provides a logging system built on the `tracing` crate. Features include:
//!
//! - Thread-safe, idempotent logger initialization
//! - Configurable log levels (DEBUG, INFO, WARN, ERROR, TRACE)
//! - Environment-variable based configuration
//! - Support for multiple platforms (with special handling for wasm32)
//!
//! **Log Levels:**
//! - `DEBUG`: Detailed debugging information
//! - `INFO`: General application status information
//! - `WARN`: Non-critical issues that require attention
//! - `ERROR`: Significant problems causing failures
//! - `TRACE`: Fine-grained application execution details
//!
//!
//! ## Usage Notes
//!
//! - The configuration system automatically initializes the logger when loading settings
//! - Logger initialization is thread-safe and only happens once
//! - Configuration can be loaded from environment variables or JSON files
//! - Credentials can be securely stored (passwords are excluded from serialization)
/// This module contains the configuration
/// and logger setup for the application.