function_sdk_rust/logging.rs
1//! Logging setup for composition functions.
2
3/// Configures process-wide logging.
4///
5/// Logs are emitted as JSON lines at info level. With debug enabled, logs
6/// are emitted in a human-readable format at debug level instead. Call once,
7/// before serving.
8pub fn configure(debug: bool) {
9 if debug {
10 tracing_subscriber::fmt()
11 .with_max_level(tracing::Level::DEBUG)
12 .with_file(true)
13 .with_line_number(true)
14 .init();
15 } else {
16 tracing_subscriber::fmt()
17 .json()
18 .with_max_level(tracing::Level::INFO)
19 .with_file(true)
20 .with_line_number(true)
21 .init();
22 }
23}