Table of Contents

 
LogItem
 

Purpose

Makes an entry into the log

 

Protoype

void CError::LogItem (string str_log_item, char* c_origin, int i_line, string str_type)
 

Parameters

log_item the string to insert into the log
origin the path of the file the error or report is originating from
line the line in the file where the error or report is coming from
type the type of error/report being logged
 

Description

This function actually inserts an error or report item into the log file. The text that will appear to explain the error or report will be passed in for str_log_item. The next two parameters, c_origin and i_line can be taken care of with the predefined compiler values of __FILE__ and __LINE__ respectively.

The type of error for str_type can be one of the following:

ERR_OK_[SYS][APP] use this type when reporting that a function has successfully completed its operation
ERR_STATUS_[SYS][APP] use this type when reporting, for example, the function of a routine, like the movement of a game object
ERR_COMMON_[SYS][APP] use this type when you know the report will be logged a lot of times (like in a loop)
ERR_WARNING_[SYS][APP] use this type when reporting something that could cause problems or if a function could not preform as expected
ERR_FATAL_[SYS][APP] use this type when reporting a fatal program error. Caution: Using this type will automatically throw an exception to exit the application
ERR_DEBUG use this type for debug information output

Each of the types with [SYS][APP] means that one or the other of the two can be appended to the error type. This lets you distinguish system errors (errors that deal with the game framework) and application errors (errors that deal with the game code). Why are there so many error types? See SetFilter() for more information.

Also, when a log item is reported the function also logs the exact time in hour:min:sec:ms below the log entry. This is not elapsed time.

 

Use

CError error;
error.LogItem("Completed loading all game objects", __FILE__, __LINE__, ERR_OK_APP);
 

Prev: LoadConfig
Next: OpenLog