# Custom debugging with macro programming

**URL:** https://discourse.julialang.org/t/custom-debugging-with-macro-programming/46191
**Category:** General Usage
**Tags:** question
**Created:** [September 7, 2020, 11:11am UTC](https://discourse.julialang.org/t/custom-debugging-with-macro-programming/46191 "2020-09-07T11:11:40Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Impressium](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/impressium/32/19575_2.png) [@Impressium](https://discourse.julialang.org/u/Impressium)
#### Post date: [September 7, 2020, 11:11am UTC](https://discourse.julialang.org/t/custom-debugging-with-macro-programming/46191/1 "2020-09-07T11:11:40Z")

</div>

How would I do the following the right way?

```julia
for sym in (:debugging, :debugging_str)
    @eval macro $sym(ex)
        quote
            $(esc(println(Dates.now(UTC), ":\t", ex)))
        end
    end
end

```

Sometimes if I use this macro in a function it doesn’t understands the scope and can’t use the variables in the function scope.

---

<div class="post-metadata">

### Author: ![Impressium](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/impressium/32/19575_2.png) [@Impressium](https://discourse.julialang.org/u/Impressium)
#### Post date: [September 7, 2020, 11:18am UTC](https://discourse.julialang.org/t/custom-debugging-with-macro-programming/46191/2 "2020-09-07T11:18:23Z")

</div>

Just looked it up in `@show`. I needed to escape the right thing^^

```julia
for sym in (:debugging, :debugging_str)
    @eval macro $sym(ex)
        quote
            println(now(UTC), ":\t", $(esc(ex)))
        end
    end
end

```
