# Prevent Trace from including package functions

Suppose MyAppFunc1 is a function inside the package MyApp. How do I prevent Trace[Func1[x]] from displaying everything inside Func1 (or what's inside any MyApp functions)?

SetAttributes[MyAppFunc1, {ReadProtected, Locked}] appears to do the job. but then I can't modify options of Func1 with SetOptions.

• What do want Trace[Func1[x]] to display if not the functions that are called inside it? After all, that's what Trace is for. – m_goldberg Jul 23 '17 at 6:00
• Why can't you? Unless you set it Protected there should be no problem. – Kuba Jul 23 '17 at 6:12
• It sounds like you know the solution: use a different public Symbol for the Options, and pass those to the Locked function that you don't want read. – Mr.Wizard Jul 23 '17 at 6:59

## 1 Answer

Just use the TraceOff option:

Func1[x_] := 2+2
Trace[Func1[x], TraceOff->_Func1]


{Func1[x],4}

If you want to kill off tracing of a whole package, you could use something like:

Trace[expr, TraceOff -> (h_[___] /; Context[h]==="MyApp")]

• That is very helpful. Do you know how to use the related $TraceOff symbol? I tried setting it to the pattern you suggested, but it didn't work for me. – QuantumDot Jul 23 '17 at 20:39 • Doing $TraceOff=patt; Trace[expr] will not work because Trace sets \$TraceOff to None (the default value of TraceOff`). – Carl Woll Jul 23 '17 at 22:34