I can't seem to get this code segment to work, pla...
# lucee
g
I can't seem to get this code segment to work, placing it under my Application.cfc onRequest function. Is there a better place for it? And I am not sure why this toggle would not work. I can only turn it on and off via the admin page so far.
Copy code
if (structKeyExists(url, "debug")) {
    request.showDebugOutput = true;
} else {
    request.showDebugOutput = false;
}
d
Did you put it in the onRequestStart function?
g
I have also tried placing it there and no dice so far 😕.
Going to set request. back to setting, also will try it 3 different functions in application.cfc
Copy code
if (structKeyExists(url, "debug")) {
            setting showDebugOutput = true;
        } else {
            setting showDebugOutput = false;
        }
d
Ah wait, are you in secure mode by chance? Is this AdobeCF?
g
This would be Lucee v5 and I am not sure if I am in secure mode or not.
I don't really see what I am doing all that different from an example like this 😕 https://gist.github.com/roryl/fca1f922ee013a4bfa8b1f67af163620.
They stuck theirs on onRequestEnd, still no dice there either.
I can get it to work via the web admin console, but then I can't turn it off. So far I have found no way to toggle it programmatically.
p
are you restarting your app after making the changes? To actually load those into the onRequestStart?
g
probably not.. one sec 😅
Yea, it still fails to work after restarting the lucee instance in cmdbox.
Good suggestion though @Patrick
So via this I am checking the status of debug before and after and it simply keeps the false value throughout.. or the true value, if I set that via the web admin.
Copy code
writedump(IsDebugMode());
if (structKeyExists(url, "debug")) {
    setting showDebugOutput = true;
} else {
    setting showDebugOutput = false;
}
writedump(IsDebugMode());
p
What version of Lucee?
g
CF Engine: lucee 5.4.3+2
Also just confirmed that the if else statement is running.
Copy code
writedump(IsDebugMode());
        if (structKeyExists(url, "debug")) {
            writedump("set to true")
            setting showDebugOutput = true;
        } else {
            writedump("set to false")
            setting showDebugOutput = false;
        }
        writedump(IsDebugMode());
So I don't know what else to set really 😕.
Wait I have it now!
Ok I think turning it on by default then setting to false and yes restarting the lucee instance is what did it.
Earlier when I restarted the lucee instance I had the logging set to off by default - needed to flip that!
Thanks guys!
👍🏻 1
It does also have to be added to the onRequestEnd function, no other place will it work.
m
setting showdebugoutput=(url.keyExists("debug")?'yes':'no'); // worked for me without needing to place in onrequestend.
👍 1