mirror of
https://github.com/Strum355/mcshader-lsp.git
synced 2025-07-24 11:44:44 +00:00
big heckin reworkerino to use the standard #line directive as per spec
This commit is contained in:
parent
cb7c9b8b49
commit
d3365c3bff
52 changed files with 574 additions and 398 deletions
12
server/logging_macro/Cargo.toml
Normal file
12
server/logging_macro/Cargo.toml
Normal file
|
@ -0,0 +1,12 @@
|
|||
[package]
|
||||
name = "logging_macro"
|
||||
version = "0.9.5"
|
||||
authors = ["Noah Santschi-Cooney <noah@santschi-cooney.ch>"]
|
||||
edition = "2021"
|
||||
|
||||
[lib]
|
||||
proc-macro = true
|
||||
|
||||
[dependencies]
|
||||
quote = "1.0"
|
||||
syn = { version = "1.0", features = [ "full" ] }
|
24
server/logging_macro/src/lib.rs
Normal file
24
server/logging_macro/src/lib.rs
Normal file
|
@ -0,0 +1,24 @@
|
|||
use proc_macro::TokenStream;
|
||||
use quote::quote;
|
||||
use syn::{parse_macro_input, parse_quote, ItemFn};
|
||||
|
||||
#[proc_macro_attribute]
|
||||
pub fn log_scope(_args: TokenStream, function: TokenStream) -> TokenStream {
|
||||
let mut function = parse_macro_input!(function as ItemFn);
|
||||
|
||||
let function_name = function.sig.ident.to_string();
|
||||
|
||||
let stmts = function.block.stmts;
|
||||
|
||||
function.block = Box::new(parse_quote!({
|
||||
use slog::{slog_o, FnValue, Level};
|
||||
use std::thread::current;
|
||||
|
||||
let _guard = logging::set_logger_with_level(Level::Trace);
|
||||
slog_scope::scope(&slog_scope::logger().new(slog_o!("test_name" => #function_name, "thread_num" => FnValue(|_| format!("{:?}", current().id())))), || {
|
||||
#(#stmts)*
|
||||
});
|
||||
}));
|
||||
|
||||
TokenStream::from(quote!(#function))
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue