flame_rs/
trace.rs

1/*
2Copyright 2025 The Flame Authors.
3Licensed under the Apache License, Version 2.0 (the "License");
4you may not use this file except in compliance with the License.
5You may obtain a copy of the License at
6    http://www.apache.org/licenses/LICENSE-2.0
7Unless required by applicable law or agreed to in writing, software
8distributed under the License is distributed on an "AS IS" BASIS,
9WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10See the License for the specific language governing permissions and
11limitations under the License.
12*/
13
14pub struct TraceFn {
15    pub fn_name: String,
16}
17
18impl TraceFn {
19    pub fn new(n: String) -> Self {
20        tracing::debug!("{n} Enter");
21        TraceFn { fn_name: n }
22    }
23}
24
25impl Drop for TraceFn {
26    fn drop(&mut self) {
27        tracing::debug!("{} Leaving", self.fn_name);
28    }
29}
30
31#[macro_export]
32macro_rules! trace_fn {
33    ($e:expr) => {
34        let _trace_fn = TraceFn::new($e.to_string());
35        // let _scope_call = TraceFn { fn_name: $e.to_string() };
36    };
37}