Changes between Initial Version and Version 1 of Logging


Ignore:
Timestamp:
Apr 15, 2013, 3:52:19 AM (11 years ago)
Author:
historic_bruno
Comment:

Initial draft

Legend:

Unmodified
Added
Removed
Modified
  • Logging

    v1 v1  
     1This 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.
     2
     3= Engine =
     4
     5The engine is written in C++. Prefer these functions for logging and outputting text:
     6
     7 * `debug_printf(const wchar_t* format, ...)`
     8 * `LOGMESSAGE(const wchar_t* format, ...)`
     9 * `LOGMESSAGERENDER(const wchar_t* format, ...)`
     10 * `LOGWARNING(const wchar_t* format, ...)`
     11 * `LOGERROR(const wchar_t* format, ...)`
     12
     13||= '''Function''' =||= '''Game console''' =||= '''Rendered message''' =||= '''Main log''' =||= '''Interesting log''' =||= '''std::out'''* =||= '''std::err''' =||
     14||`debug_printf` ||  N  ||  N  ||  N  ||  N  ||  Y  ||  N  ||
     15||`LOGMESSAGE` ||  N  ||  N  ||  Y  ||  N  ||  N  ||  N  ||
     16||`LOGMESSAGERENDER` ||  Y  ||  Y - green text  ||  Y  ||  N  ||  N  ||  N  ||
     17||`LOGWARNING` ||  Y  ||  Y - yellow text  ||  Y  ||  Y  ||  Y  ||  N  ||
     18||`LOGERROR` ||  Y  ||  Y - red text  ||  Y  ||  Y  ||  Y  ||  N  ||
     19 `*` 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]]
     20
     21'''Note:''' to use the `LOG*` functions, you must include [source:/ps/trunk/source/ps/CLogger.h ps/Clogger.h].[[BR]]
     22'''Note:''' these functions accept standard printf formatting and arguments, and use wide characters, which requires prefixing string literals with 'L':
     23{{{
     24#!c++
     25std::string name;
     26// ... some code here ...
     27debug_printf(L"This is not a very interesting message, %hs\n", name.c_str());
     28}}}
     29
     30= Scripts =
     31
     32The 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:
     33
     34 * `print(message)`
     35 * `console.write(message)`
     36 * `log(message)`
     37 * `warn(message)`
     38 * `error(message)`
     39
     40||= '''Function''' =||= '''Game console''' =||= '''Rendered message''' =||= '''Main log''' =||= '''Interesting log''' =||= '''std::out'''* =||= '''std::err''' =||
     41||`print` ||  N  ||  N  ||  N  ||  N  ||  Y  ||  N  ||
     42||`console.write` ||  Y  ||  N  ||  N  ||  N  ||  N  ||  N  ||
     43||`log` ||  N  ||  N  ||  Y  ||  N  ||  N  ||  N  ||
     44||`warn` ||  Y  ||  Y - yellow text  ||  Y  ||  Y  ||  Y  ||  N  ||
     45||`error` ||  Y  ||  Y - red text  ||  Y  ||  Y  ||  Y  ||  N  ||
     46 `*` 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]]