lib.rs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. use proc_macro::TokenStream;
  2. use syn::parse_macro_input;
  3. mod expand;
  4. #[proc_macro]
  5. pub fn log(args: TokenStream) -> TokenStream {
  6. let args = parse_macro_input!(args as expand::LogArgs);
  7. expand::log(args, None)
  8. .unwrap_or_else(|err| err.to_compile_error())
  9. .into()
  10. }
  11. #[proc_macro]
  12. pub fn error(args: TokenStream) -> TokenStream {
  13. let args = parse_macro_input!(args as expand::LogArgs);
  14. expand::error(args)
  15. .unwrap_or_else(|err| err.to_compile_error())
  16. .into()
  17. }
  18. #[proc_macro]
  19. pub fn warn(args: TokenStream) -> TokenStream {
  20. let args = parse_macro_input!(args as expand::LogArgs);
  21. expand::warn(args)
  22. .unwrap_or_else(|err| err.to_compile_error())
  23. .into()
  24. }
  25. #[proc_macro]
  26. pub fn info(args: TokenStream) -> TokenStream {
  27. let args = parse_macro_input!(args as expand::LogArgs);
  28. expand::info(args)
  29. .unwrap_or_else(|err| err.to_compile_error())
  30. .into()
  31. }
  32. #[proc_macro]
  33. pub fn debug(args: TokenStream) -> TokenStream {
  34. let args = parse_macro_input!(args as expand::LogArgs);
  35. expand::debug(args)
  36. .unwrap_or_else(|err| err.to_compile_error())
  37. .into()
  38. }
  39. #[proc_macro]
  40. pub fn trace(args: TokenStream) -> TokenStream {
  41. let args = parse_macro_input!(args as expand::LogArgs);
  42. expand::trace(args)
  43. .unwrap_or_else(|err| err.to_compile_error())
  44. .into()
  45. }