From AGI Wiki
Jump to: navigation, search

The log command adds an entry to the game's log file.


log(msg mLOGMSG);
log("log message");


The log command is often used during debugging of games. It allows the programmer to capture some basic information and save it to a file that can later be examined to make corrections and improvements to a game.

If the game's log file (named 'logfile') does not exist in the game's directory, it will be automatically created. If the file already exists, the log entry is appended to the existing file.

The logfile entry is written in three lines, in the following format:
Room <#>
Input line: <text>

The room number is the current value if reserved variable v0. The input line value is the most recent line of text that was entered on the input line. The text of message mLOGMSG is added as the last line.

If AGI encounters any file errors while trying to open or write to the logfile, it just ignores the errors, and does not write the log file entry.

Possible Errors



[ commonly used entry to track which words players are 
[ using in a game; can help improve the WORDS.TOK file
if (!isset(haveMatch) && isset(haveInput) && unknownWord > 0) 
  if (unknownWord == 1)
    log("Unknown word: %w1");
  [ repeat for the other possible word numbers
  if (unknownWord == 10) 
    log("Unknown word: %w10");
  print("Logged an unknown word.");

Technical Information

Required Interpreter Version: Available in all AGI versions.
Byte-Code Value: 144 (0x90 hex)

See Also

Debugging Commands
AGI Debugging Information