How to properly call Debug.Log(string) in a custom Log function?

I’d like to create an alternate version of Debug.Log(string): ConidtionalDebugLog(string).
I’d simply like to wrap the debug statement in a few conditionals, based on settings. That part works fine.

The issue I’m hitting is with the “non-string” part of the log, in particular the stack trace. As one would expect, the error in the console shows the line that the Debug.Log() function was called, both in the stack trace, and when double clicking the message to open the script file to that line.

Ideally, I would like to have the console show (and go to, on double click) the line of code that called ConditionalDebugLog(string), instead of the line of code INSIDE ConditionalDebugLog() that called Debug.Log().

I’ve tried going through the docs on the various ILogger, ILogHandler interfaces, in order to try understanding how Debug.logger works, but I’m still not clear on if this stuff can even help the objective.

Is this possible? Is it practical? If so, any suggestions?
Any ideas for alternatives also welcome.

Compile the ConditionalDebugLog code into a DLL.