This page documents some ways of logging and outputting text in the game, both within the engine and scripts. This is useful to know for debugging and when the user should be notified of something. = Engine = The engine is written in C++. Prefer these functions for logging and outputting text: * `debug_printf(const wchar_t* format, ...)` * `LOGMESSAGE(const wchar_t* format, ...)` * `LOGMESSAGERENDER(const wchar_t* format, ...)` * `LOGWARNING(const wchar_t* format, ...)` * `LOGERROR(const wchar_t* format, ...)` ||= '''Function''' =||= '''Game console''' =||= '''Rendered message''' =||= '''Main log''' =||= '''Interesting log''' =||= '''std::out'''* =||= '''std::err''' =|| ||`debug_printf` || N || N || N || N || Y || N || ||`LOGMESSAGE` || N || N || Y || N || N || N || ||`LOGMESSAGERENDER` || Y || Y - green text || Y || N || N || N || ||`LOGWARNING` || Y || Y - yellow text || Y || Y || Y || N || ||`LOGERROR` || Y || Y - red text || Y || Y || Y || N || `*` On Windows, the game writes debug output instead of std::out. Run the game in a debugger or use [http://technet.microsoft.com/en-us/sysinternals/bb896647.aspx DebugView] to view it.[[BR]] '''Note:''' to use the `LOG*` functions, you must include [source:/ps/trunk/source/ps/CLogger.h ps/Clogger.h].[[BR]] '''Note:''' these functions accept standard printf formatting and arguments, and use wide characters, which requires prefixing string literals with 'L': {{{ #!c++ std::string name; // ... some code here ... debug_printf(L"This is not a very interesting message, %hs\n", name.c_str()); }}} = Scripts = The game's scripts are written in JavaScript, but they won't necessarily have the same functions available as in a web browser. Use these functions for outputting text: * `print(message)` * `console.write(message)` * `log(message)` * `warn(message)` * `error(message)` ||= '''Function''' =||= '''Game console''' =||= '''Rendered message''' =||= '''Main log''' =||= '''Interesting log''' =||= '''std::out'''* =||= '''std::err''' =|| ||`print` || N || N || N || N || Y || N || ||`console.write` || Y || N || N || N || N || N || ||`log` || N || N || Y || N || N || N || ||`warn` || Y || Y - yellow text || Y || Y || Y || N || ||`error` || Y || Y - red text || Y || Y || Y || N || `*` On Windows, the game writes debug output instead of std::out. Run the game in a debugger or use [http://technet.microsoft.com/en-us/sysinternals/bb896647.aspx DebugView] to view it.[[BR]]