organic/src/main.rs

43 lines
1.3 KiB
Rust
Raw Normal View History

2023-03-23 23:35:32 +00:00
#![feature(round_char_boundary)]
2023-03-25 15:27:38 +00:00
use crate::parser::document;
2023-03-27 19:08:29 +00:00
use tracing_subscriber::EnvFilter;
2022-07-16 03:26:49 +00:00
mod parser;
2023-03-27 21:06:22 +00:00
use tracing_subscriber::layer::SubscriberExt;
use tracing_subscriber::util::SubscriberInitExt;
2022-07-16 03:26:49 +00:00
const TEST_DOC: &'static str = include_str!("../toy_language.txt");
fn main() -> Result<(), Box<dyn std::error::Error>> {
2023-03-27 19:08:29 +00:00
init_telemetry()?;
let parsed = document(TEST_DOC);
println!("{}\n\n\n", TEST_DOC);
println!("{:#?}", parsed);
opentelemetry::global::shutdown_tracer_provider();
2023-03-27 19:08:29 +00:00
Ok(())
}
fn init_telemetry() -> Result<(), Box<dyn std::error::Error>> {
let env_filter = EnvFilter::try_from_default_env().unwrap_or(EnvFilter::new("WARN"));
2023-03-27 21:06:22 +00:00
// let stdout = tracing_subscriber::fmt::Layer::new()
// .pretty()
// .with_file(true)
// .with_line_number(true)
// .with_thread_ids(false)
// .with_target(false);
2023-03-27 21:06:22 +00:00
opentelemetry::global::set_text_map_propagator(opentelemetry_jaeger::Propagator::new());
let tracer = opentelemetry_jaeger::new_pipeline()
.with_service_name("toy_language")
.install_simple()?;
let opentelemetry = tracing_opentelemetry::layer().with_tracer(tracer);
tracing_subscriber::registry()
.with(env_filter)
.with(opentelemetry)
// .with(stdout)
2023-03-27 21:06:22 +00:00
.try_init()?;
2022-07-16 03:26:49 +00:00
Ok(())
}