Demonstrates
-
ApplicationProperties.OnLog, which allows you to register custom callbacks that receive all log messages. -
Using
TCastleDownloadto send HTTP POST request.
Put together, this demo sends HTTP POST message (to a hardcoded URL https://castle-engine.io/cge_logger.php handled by PHP) on each CGE log message.
In effect, you can view logs remotely.
Usage:
-
Just run and press any keys or mouse buttons. They will cause
WritelnLog, which will be send to your server usign asynchronous HTTP POST. -
Be sure to edit your server name in
gameloghandler.pas. You need a simplest HTTP server that handles PHP. Use the PHP code fromsample_php_server_logger/cge_logger.php.
Note that only logs send to CGE CastleLog (like WritelnLog, WritelnWarning) are captured this way. Other stuff being written e.g. to stdout or stderr is not captured using ApplicationProperties.OnLog.
Using Castle Game Engine.
Both FPC and Delphi code paths use OpenSSL to implement HTTPS support.
We strongly advise to compile at least once using CGE editor that will place the appropriate DLLs automatically alongside your EXE. Afterwards you can build using CGE editor or from Delphi or Lazarus IDEs, the DLLs will be in place.
If you really must do it manually, get the 2 necessary DLLs from these locations:
Compile by:
-
CGE editor. Just use menu items "Compile" or "Compile And Run".
-
Or use CGE command-line build tool. Run
castle-engine compilein this directory. -
Or use Lazarus. Open in Lazarus
remote_logging_standalone.lpifile and compile / run from Lazarus. Make sure to first register CGE Lazarus packages. -
Or use Delphi. Open in Delphi
remote_logging_standalone.dprojfile and compile / run from Delphi. See CGE and Delphi documentation for details.
