Forum > Beginners
How to hide console correctly?
taazz:
--- Quote from: Eugene Loza on January 26, 2016, 09:52:01 am ---
--- Quote from: taazz on January 26, 2016, 09:50:13 am ---True! so? Enable it only when compiling a release version.
--- End quote ---
Well Then I get exception on writeln(...); I need to rewrite up to 50 debug messages from different modules of the program to console... maybe I'll rewrite that part later, but not now.
--- End quote ---
A well deserved punishment. Use an ($ifdef debug}writeln(...){$ENDIF} and stop polluting your code with debug code.
--- Quote from: Eugene Loza on January 26, 2016, 09:52:01 am ---I just want the console behavior in Windows the same as in Linux.
--- End quote ---
Yeah and I want a environmentally friendly, no noise, no fuel generator for each house with a life time of at least 1000 years, but in both cases that is not the way things work.
Martin_fr:
just replace "writeln" with "debugln"
debugln checks correctly if the console is open, or not.
also it does logging if you want, and start your app with --debug-log=file
and you can use the unit LazDummyLogger (or similar, not sure) to disable it entirely
Eugene Loza:
--- Quote from: Martin_fr on January 26, 2016, 03:43:03 pm ---just replace "writeln" with "debugln"
--- End quote ---
Thanks, but that's also won't work, because I send ~10% of debug messages from threads (that's where I need them most) and debugln is not thread-friendly.
After 3 days of skimming through the Internet I have to confirm taazz is right. It's implssible in Windows. I'll just use log file then.
Well... practically possible (hide the window as in tray applications) - but it is not the best idea.
taazz:
--- Quote from: Eugene Loza on January 27, 2016, 10:05:24 am ---
--- Quote from: Martin_fr on January 26, 2016, 03:43:03 pm ---just replace "writeln" with "debugln"
--- End quote ---
Thanks, but that's also won't work, because I send ~10% of debug messages from threads (that's where I need them most) and debugln is not thread-friendly.
After 3 days of skimming through the Internet I have to confirm taazz is right. It's implssible in Windows. I'll just use log file then.
Well... practically possible (hide the window as in tray applications) - but it is not the best idea.
--- End quote ---
OK, how about this. Instead of messing with the console window go the other way, assign a null device to stdout, stdin and stderror, this should in theory, allow writeln to work with out exceptions. Sorry for the delay but I just remembered I show a unit that did something along those lines in delphi I'll take a look in my archives when I get home.
Eugene Loza:
--- Quote ---I'll take a look in my archives when I get home.
--- End quote ---
Thanks a lot. But don't bother... I've run into a huge X3D-related "bug" (feature actually) and will have to rewrite a lot of code. I'll just route everything to log file then, that'll solve the problem in a correct way. I've seen solutions by something like: http://forum.lazarus.freepascal.org/index.php/topic,30642.msg195490.html#msg195490 but that's a little bit too-low-level. I needed it simpler...
Well... that day was inevitable %) I'll still need users to be able to sumbit logs. It just came a little bit too early ::)
I was just hoping that I'm missing something simple.
Navigation
[0] Message Index
[*] Previous page