-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.rs
More file actions
46 lines (36 loc) · 1019 Bytes
/
main.rs
File metadata and controls
46 lines (36 loc) · 1019 Bytes
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
mod opts;
mod parser;
mod server;
mod document_store;
mod documentation;
mod utils;
use std::fs::File;
use std::io::stderr;
use anyhow::Result;
use clap::Parser;
use structured_logger::json::new_writer;
use structured_logger::Builder;
use self::opts::DrupalLspConfig;
use self::server::start_lsp;
#[tokio::main]
async fn main() -> Result<()> {
let config = DrupalLspConfig::parse();
let mut builder = Builder::with_level(&config.level);
if let Some(file) = &config.file {
let log_file = File::options()
.create(true)
.append(true)
.open(file)
.unwrap();
builder = builder.with_target_writer("*", new_writer(log_file));
} else {
builder = builder.with_target_writer("*", new_writer(stderr()))
}
builder.init();
log::trace!("log options: {:?}", config);
match start_lsp(config).await {
Ok(_) => (),
Err(error) => log::error!("An unexpected error happened: {:?}", error),
};
Ok(())
}