This page has been translated automatically.
Видеоуроки
Интерфейс
Основы
Продвинутый уровень
Подсказки и советы
Основы
Программирование на C#
Рендеринг
Профессиональный уровень (SIM)
Принципы работы
Свойства (properties)
Компонентная Система
Рендер
Физика
Редактор UnigineEditor
Обзор интерфейса
Работа с ассетами
Контроль версий
Настройки и предпочтения
Работа с проектами
Настройка параметров ноды
Setting Up Materials
Настройка свойств
Освещение
Sandworm
Использование инструментов редактора для конкретных задач
Расширение функционала редактора
Встроенные объекты
Ноды (Nodes)
Объекты (Objects)
Эффекты
Декали
Источники света
Geodetics
World-ноды
Звуковые объекты
Объекты поиска пути
Player-ноды
Программирование
Основы
Настройка среды разработки
Примеры использования
C++
C#
UnigineScript
UUSL (Unified UNIGINE Shader Language)
Плагины
Форматы файлов
Материалы и шейдеры
Rebuilding the Engine Tools
Интерфейс пользователя (GUI)
Двойная точность координат
API
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Objects-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
IG Plugin
CIGIConnector Plugin
Rendering-Related Classes
Работа с контентом
Оптимизация контента
Материалы
Визуальный редактор материалов
Сэмплы материалов
Material Nodes Library
Miscellaneous
Input
Math
Matrix
Textures
Art Samples
Учебные материалы
Внимание! Эта версия документация УСТАРЕЛА, поскольку относится к более ранней версии SDK! Пожалуйста, переключитесь на самую актуальную документацию для последней версии SDK.
Внимание! Эта версия документации описывает устаревшую версию SDK, которая больше не поддерживается! Пожалуйста, обновитесь до последней версии SDK.

Unigine::Log Class

Header: #include <UnigineLog.h>

This class represents an interface for printing various types of messages to the console and to the Engine's log file. It can be useful to monitor overall progress of application execution and report errors which can be helpful in the process of debugging.

Notice
To enable displaying system messages in the Console use the following command: console_onscreen 1

There are two custom color schemes highlighting log syntax for Notepad++ included in the SDK:

  • <SDK>/utils/log_styles/notepad_light.xml
  • <SDK>/utils/log_styles/notepad_dark.xml
Notice
By default all logged messages are saved to the Engine's log file, and printed to stdout, the latter may significantly affect peformance in case of much logging. If logging causes performance issues, you can control the two logging targets via the following console commands:

Example#

The following code demonstrates how to print various types of messages.

Source code (C++)
using namespace Unigine;

// auxiliary variables for messages
const char* file_name = "file.txt";
int ID = 10;

	// reporting an error message
	Log::error("Loading mesh: can't open \"%s\" file\n", file_name);

	// reporting a message
	Log::message("-> Added %d UI elements.\n", ID);

	// reporting a warning message
	Log::warning("ID of the \"%s\" file: %d.\n", file_name, ID);

	// reporting a fatal error message to the log file and closing the application
	Log::fatal("FATAL ERROR reading \"%s\" file!\n", file_name);

Adding Callbacks#

You can add callbacks to define custom actions on various types of messages printed to the Log. The signature of the callback function must be as follows:

Source code (C++)
void callback_function_name(const char * message_text);
Here is an example of tracking error messages via callbacks:
Source code (C++)
void error_callback(const char * message_text)
{
	std::cout<<"My message is: "<<message_text<<std::endl; 
    // ...
}

// somewhere in the code

// setting our callback function on an error message
Log::addCallback(Log::CALLBACK_ERROR, MakeCallback(error_callback));

// printing an error message to the Log
Log::error("An ERROR has occurred!\n");

Log Class

Enums

CALLBACK_INDEX#

ИмяОписание
CALLBACK_MESSAGE = 0Callback to be fired on a message.
CALLBACK_WARNING = 1Callback to be fired on a warning message.
CALLBACK_ERROR = 2Callback to be fired on an error message.
CALLBACK_FATAL = 3Callback to be firen on a fatal error message.
CALLBACK_COUNT = 4Number of Log class callbacks.

Members


void error ( const char * format, ... ) #

Prints an error message to the console and the log file.

Arguments

  • const char * format - Error message to print.
  • ... - Arguments, multiple allowed.

void fatal ( const char * format, ... ) #

Prints a fatal error message to the log file and quits the engine.

Arguments

  • const char * format - Fatal error message to print.
  • ... - Arguments, multiple allowed.

void message ( const char * format, ... ) #

Prints a message to the console and the log file.

Arguments

  • const char * format - Message to print.
  • ... - Arguments, multiple allowed.

void warning ( const char * format, ... ) #

Prints a warning to the console and the log file.

Arguments

  • const char * format - Warning to print.
  • ... - Arguments, multiple allowed.

void * addCallback ( CALLBACK_INDEX callback, Unigine::CallbackBase1< const char * > * func ) #

Adds a callback of the specified type. Callback functions can be used to determine actions to be performed when any type of message is printed. Here is an example of tracking error messages via callbacks:
Source code (C++)
void error_callback(const char * message_text)
{
	std::cout<<"My message is: "<<message_text<<std::endl; 
    // ...
}

// somewhere in the code

// setting our callback function on an error message
Log::addCallback(Log::CALLBACK_ERROR, MakeCallback(error_callback));

// printing an error message to the Log
Log::error("An ERROR has occurred!\n");

Arguments

  • CALLBACK_INDEX callback - Callback type. One of the CALLBACK_* variables.
  • Unigine::CallbackBase1< const char * > * func - Callback pointer. The signature of the callback function must be as follows:
    void callback_function_name(const char * message_text);

Return value

ID of the last added callback of the specified type, if the callback was added successfully; otherwise, nullptr. This ID can be used to remove this callback when necessary.

bool removeCallback ( CALLBACK_INDEX callback, void * id ) #

Removes the specified callback from the list of callbacks of the specified type. Callback functions can be used to determine actions to be performed when any type of message is printed.

Arguments

Return value

True if the callback with the given ID was removed successfully; otherwise false.

void clearCallbacks ( CALLBACK_INDEX callback ) #

Clears all added callbacks of the specified type. Callback functions can be used to determine actions to be performed when any type of message is printed.

Arguments

bool hasCallback ( CALLBACK_INDEX callback ) #

Returns a value indicating if at least one callback of the given type is set. Callback functions can be used to determine actions to be performed when any type of message is printed.

Arguments

Return value

True if at least one callback of the given type is set; otherwise false.
Last update: 17.11.2023
Build: ()