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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
//! Logging functionality for http-wasm guest plugins.
//!
//! This module provides logging capabilities that integrate with the http-wasm host
//! environment. Log messages are forwarded to the host, which handles the actual
//! output according to its configuration.
//!
//! # Setup
//!
//! Initialize logging early in your plugin's `main()` function:
//!
//! ```no_run
//! use http_wasm_guest::host;
//! use log::{info, warn, error};
//!
//! fn main() {
//! // Initialize with default Info level
//! host::log::init().expect("Failed to initialize logger");
//!
//! // Or initialize with a specific level
//! // host::log::init_with_level(log::Level::Debug).expect("Failed to initialize logger");
//!
//! // Now you can use standard Rust logging macros
//! info!("Plugin initialized");
//! warn!("This is a warning");
//! error!("This is an error");
//! }
//! ```
//!
//! # Log Levels
//!
//! The following log levels are supported (from most to least verbose):
//! - `Error` - Error messages
//! - `Warn` - Warning messages
//! - `Info` - Informational messages (default)
//! - `Debug` - Debug messages (not supported by all hosts)
//! - `Trace` - Trace messages (not supported by all hosts)
//!
//! # Host Integration
//!
//! - Log messages are sent to the http-wasm host for processing
//! - The host determines the final output format and destination
//! - Some hosts may not support all log levels (Debug/Trace are often disabled)
//! - Log output depends on the host's logging configuration
use ;
use handler;
static LOGGER: HostLogger = HostLogger ;
static LVL: = ;
/// Initializes the http-wasm logger with a specific log level.
///
/// This function sets up logging to route log messages through the http-wasm host
/// environment. The host will handle the actual logging output according to its
/// own configuration.
///
/// # Parameters
///
/// - `level`: The maximum log level to enable (e.g., `Level::Info`, `Level::Debug`)
///
/// # Returns
///
/// Returns `Ok(())` if the logger was successfully initialized, or a `SetLoggerError`
/// if a logger was already set.
///
/// # Example
///
/// ```no_run
/// use http_wasm_guest::host::log::init_with_level;
/// use log::Level;
///
/// fn main() {
/// init_with_level(Level::Debug).expect("Failed to initialize logger");
/// log::info!("Logger initialized with debug level");
/// }
/// ```
///
/// # Notes
///
/// - This should be called early in your plugin's `main()` function
/// - Only call this once per module - subsequent calls will return an error
/// - The actual log output format and destination depends on the host implementation
/// Initializes the http-wasm logger with the default Info log level.
///
/// This is a convenience function that calls [`init_with_level`] with `Level::Info`.
/// Use this when you want standard logging without debug messages.
///
/// # Returns
///
/// Returns `Ok(())` if the logger was successfully initialized, or a `SetLoggerError`
/// if a logger was already set.
///
/// # Example
///
/// ```no_run
/// use http_wasm_guest::host::log::init;
///
/// fn main() {
/// init().expect("Failed to initialize logger");
/// log::info!("Logger initialized");
/// log::warn!("This will be logged");
/// log::debug!("This will NOT be logged (below Info level)");
/// }
/// ```
///
/// # Notes
///
/// - Equivalent to calling `init_with_level(Level::Info)`
/// - This should be called early in your plugin's `main()` function
/// - Only call this once per module - subsequent calls will return an error
///
/// [`init_with_level`]: init_with_level