For newer Delphi versions with OSX and Android support, is there a platform-independent detection method if Writeln before Output can be used safely?
The output documentation contains a note in which
Most processes do not have a standard output file and writing to the result causes an error. Delphi files have a standard output file if they are linked as console applications.
My main goal is to have a platform-independent logging reserve, but to avoid OS errors that can occur when the console (stdout) is missing.
For example: it would be enough to check IsConsole like this:
procedure Log(const Msg: string);
begin
if LoggingFrameworkAvailable then
begin
// use the logging framework to output the log message
end if System.IsConsole then
begin
// fallback to stdout logging
WriteLn(Msg);
end;
end;
, : " Delphi Output, IsConsole - ?".
, , "" ( /dev/null ), .
, Free Pascal? (. Windows GUI, Lazarus, ?)