THRIFT-2202 Delphi TServerImpl.DefaultLogDelegate may stop the server with I/O-Error 105
Patch: Jens Geyer
diff --git a/lib/delphi/src/Thrift.Server.pas b/lib/delphi/src/Thrift.Server.pas
index 7d39f6b..6d3ff38 100644
--- a/lib/delphi/src/Thrift.Server.pas
+++ b/lib/delphi/src/Thrift.Server.pas
@@ -19,10 +19,12 @@
unit Thrift.Server;
+{$I-} // prevent annoying errors with default log delegate and no console
+
interface
uses
- SysUtils,
+ Windows, SysUtils,
Thrift,
Thrift.Protocol,
Thrift.Transport;
@@ -188,7 +190,12 @@
class procedure TServerImpl.DefaultLogDelegate( const str: string);
begin
- Writeln( str );
+ try
+ Writeln( str);
+ if IoResult <> 0 then OutputDebugString(PChar(str));
+ except
+ OutputDebugString(PChar(str));
+ end;
end;
constructor TServerImpl.Create( const AProcessor: IProcessor;