Log - SWTube/Darkest-Cave GitHub Wiki

Log

  • defined in header "Debug/Log.h"

The class Log provides support for logging messages in the engine. Log is used to print log messages to console output

Global objects

Type Definition
Log LogManager
MAX_BUFFER 255
eLogVerbosity AllVerboseDebugInfoWarnErrorAssert
eLogChannel GRAPHICS = 0x00PHYSICS = 0x20AUDIO = 0x40AI = 0x60GAMEPLAY = 0x80CORE = 0xa0CORE_MODULE = 0xa1CORE_UNIT_TEST = 0xa2CORE_MEMORY = 0xa3CORE_MATH = 0xa4CORE_STRING = 0xa5CORE_LOCALIZATION = 0xa6CORE_PARSER = 0xa7CORE_PROFILE = 0xa8CORE_ENGINE_CONFIG = 0xa9CORE_RNG = 0xaaCORE_OBJECT = 0xabCORE_THREAD = 0xacCORE_CONTAINER = 0xadCORE_FILE_SYSTEM = 0xaeCORE_TIMER = 0xafCORE_RESOURCE_MANAGER = 0xb0

Member functions

SetVerbosity

static void SetVerbosity(eLogVerbosity verbosity);

Sets the current verbosity level.

Parameters

verbosity - verbosity level to set

Example

#include "Core.h"

int main()
{
    Log::SetVerbosity(eLogVerbosity::DEBUG);

    return 0;
}

Verbose / LOGV

static void Verbose(
	eLogChannel channel,
	const char* fileName,
	const char* functionName,
	int32_t lineNumber,
	std::ostream& os,
	const char* message
);
#define LOGV(channel, os, message) cave::LogManager::Verbose(channel, __FILE__, __func__, __LINE__, os, message)
  • WIN32
    • Prints verbose log message to Win32 debug console.
  • UNIX
    • Prints verbose log message in white color to corresponding channel's stdout.

Example

  • Samples/Main.cpp
#include "Debug/Log.h"

int main()
{
    LOGV(eLogChannel::CORE, std::cout, "Hello, World!");

    return 0;
}

Output:

Core/V/../../../Samples/Main.cpp/main/line:5 :    Hello, World!

VerboseF / LOGVF

static void VerboseF(
	eLogChannel channel,
	const char* fileName,
	const char* functionName,
	int32_t lineNumber,
	std::ostream& os,
	const char* message,
	...
);
#define LOGVF(channel, os, message, ...) cave::LogManager::Verbose(channel, __FILE__, __func__, __LINE__, os, message, ...)
  • WIN32
    • Prints formatted verbose log message to Win32 debug console.
  • UNIX
    • Prints formatted verbose log message in white color to corresponding channel's stdout.

Example

  • Samples/Main.cpp
#include "Debug/Log.h"

int main()
{
    LOGVF(eLogChannel::CORE, std::cout, "1 + 1 = %d", 2);

    return 0;
}

Output:

Core/V/../../../Samples/Main.cpp/main/line:5 :    1 + 1 = 2

Debug / LOGD

static void Debug(
	eLogChannel channel,
	const char* fileName, 
	const char* functionName, 
	int32_t lineNumber, 
	std::ostream& os, 
	const char* message
);
#define LOGD(channel, os, message) cave::LogManager::Debug(channel, __FILE__, __func__, __LINE__, os, message)
  • WIN32
    • Prints debug log message to Win32 debug console.
  • UNIX
    • Prints debug log message in green color to corresponding channel's stdout.

Example

  • Samples/Main.cpp
#include "Debug/Log.h"

int main()
{
    LOGD(eLogChannel::CORE, std::cout, "Hello, World!");

    return 0;
}

Output:

Core/D/../../../Samples/Main.cpp/main/line:5 :    Hello, World!

DebugF / LOGDF

static void DebugF(
	eLogChannel channel,
	const char* fileName,
	const char* functionName,
	int32_t lineNumber,
	std::ostream& os,
	const char* message,
	...
);
#define LOGDF(channel, os, message, ...) cave::LogManager::DebugF(channel, __FILE__, __func__, __LINE__, os, message, ...)
  • WIN32
    • Prints formatted debug log message to Win32 debug console.
  • UNIX
    • Prints formatted debug log message in green color to corresponding channel's stdout.

Example

  • Samples/Main.cpp
#include "Debug/Log.h"

int main()
{
    LOGDF(eLogChannel::CORE, std::cout, "1 + 1 = %d", 2);

    return 0;
}

Output:

Core/D/../../../Samples/Main.cpp/main/line:5 :    1 + 1 = 2

Info / LOGI

static void Info(
	eLogChannel channel, 
	const char* fileName, 
	const char* functionName, 
	int32_t lineNumber, 
	std::ostream& os, 
	const char* message
);
#define LOGI(channel, os, message) cave::LogManager::Info(channel, __FILE__, __func__, __LINE__, os, message)
  • WIN32
    • Prints informational log message to Win32 debug console.
  • UNIX
    • Prints informational log message in yellow color to corresponding channel's stdout.

Example

  • Samples/Main.cpp
#include "Debug/Log.h"

int main()
{
    LOGI(eLogChannel::CORE, std::cout, "Hello, World!");

    return 0;
}

Output:

Core/I/../../../Samples/Main.cpp/main/line:5 :    Hello, World!

InfoF / LOGIF

static void InfoF(
	eLogChannel channel, 
	const char* fileName, 
	const char* functionName, 
	int32_t lineNumber, 
	std::ostream& os, 
	const char* message,
	...
);
#define LOGIF(channel, os, message, ...) cave::LogManager::InfoF(channel, __FILE__, __func__, __LINE__, os, message, ...)
  • WIN32
    • Prints formatted informational log message to Win32 debug console.
  • UNIX
    • Prints formatted informational log message in yellow color to corresponding channel's stdout.

Example

  • Samples/Main.cpp
#include "Debug/Log.h"

int main()
{
    LOGIF(eLogChannel::CORE, std::cout, "1 + 1 = %d", 2);

    return 0;
}

Output:

Core/I/../../../Samples/Main.cpp/main/line:5 :    1 + 1 = 2

Warn / LOGW

static void Warn(
	eLogChannel channel, 
	const char* fileName, 
	const char* functionName, 
	int32_t lineNumber, 
	std::ostream& os, 
	const char* message
);
#define LOGW(channel, os, message) cave::LogManager::Warn(channel, __FILE__,__func__,  __LINE__, os, message)
  • WIN32
    • Prints warning log message to Win32 debug console.
  • UNIX
    • Prints warning log message in magenta color to corresponding channel's stdout.

Example

  • Samples/Main.cpp
#include "Debug/Log.h"

int main()
{
    LOGW(eLogChannel::CORE, std::cout, "Hello, World!");

    return 0;
}

Output:

Core/W/../../../Samples/Main.cpp/main/line:5 :    Hello, World!

WarnF / LOGWF

static void WarnF(
	eLogChannel channel, 
	const char* fileName, 
	const char* functionName, 
	int32_t lineNumber, 
	std::ostream& os, 
	const char* message,
	...
);
#define LOGWF(channel, os, message, ...) cave::LogManager::WarnF(channel, __FILE__, __func__, __LINE__, os, message, ...)
  • WIN32
    • Prints formatted warning log message to Win32 debug console.
  • UNIX
    • Prints formatted warning log message in magenta color to corresponding channel's stdout.

Example

  • Samples/Main.cpp
#include "Debug/Log.h"

int main()
{
    LOGWF(eLogChannel::CORE, std::cout, "1 + 1 = %d", 2);

    return 0;
}

Output:

Core/W/../../../Samples/Main.cpp/main/line:5 :    1 + 1 = 2

Error / LOGE

static void Error(
	eLogChannel channel, 
	const char* fileName, 
	const char* functionName, 
	int32_t lineNumber, 
	std::ostream& os, 
	const char* message
);
#define LOGE(channel, os, message) cave::LogManager::Error(channel, __FILE__, __func__, __LINE__, os, message)
  • WIN32
    • Prints error log message to Win32 debug console.
  • UNIX
    • Prints error log message in red color to corresponding channel's stdout.

Example

  • Samples/Main.cpp
#include "Debug/Log.h"

int main()
{
    LOGE(eLogChannel::CORE, std::cout, "Hello, World!");

    return 0;
}

Output:

Core/E/../../../Samples/Main.cpp/main/line:5 :    Hello, World!

ErrorF / LOGEF

static void ErrorF(
	eLogChannel channel, 
	const char* fileName, 
	const char* functionName, 
	int32_t lineNumber, 
	std::ostream& os, 
	const char* message,
	...
);
#define LOGEF(channel, os, message, ...) cave::LogManager::ErrorF(channel, __FILE__, __func__, __LINE__, os, message, ...)
  • WIN32
    • Prints formatted error log message to Win32 debug console.
  • UNIX
    • Prints formatted error log message in red color to corresponding channel's stdout.

Example

  • Samples/Main.cpp
#include "Debug/Log.h"

int main()
{
    LOGEF(eLogChannel::CORE, std::cout, "1 + 1 = %d", 2);

    return 0;
}

Output:

Core/E/../../../Samples/Main.cpp/main/line:5 :    1 + 1 = 2

Assert / LOGA

static void Assert(
	eLogChannel channel, 
	const char* fileName, 
	const char* functionName, 
	int32_t lineNumber, 
	std::ostream& os, 
	const char* message
);
#define LOGA(channel, os, message) cave::LogManager::Assert(channel, __FILE__, __func__, __LINE__, os, message)
  • WIN32
    • Prints assert log message to Win32 debug console.
  • UNIX
    • Prints assert log message in cyan color to corresponding channel's stdout.

Example

  • Samples/Main.cpp
#include "Debug/Log.h"

int main()
{
    LOGA(eLogChannel::CORE, std::cout, "Hello, World!");

    return 0;
}

Output:

Core/A/../../../Samples/Main.cpp/main/line:5 :    Hello, World!

AssertF / LOGAF

static void AssertF(
	eLogChannel channel, 
	const char* fileName, 
	const char* functionName, 
	int32_t lineNumber, 
	std::ostream& os, 
	const char* message,
	...
);
#define LOGAF(channel, os, message, ...) cave::LogManager::AssertF(channel, __FILE__, __func__, __LINE__, os, message, ...)
  • WIN32
    • Prints formatted assert log message to Win32 debug console.
  • UNIX
    • Prints formatted assert log message in cyan color to corresponding channel's stdout.

Example

  • Samples/Main.cpp
#include "Debug/Log.h"

int main()
{
    LOGAF(eLogChannel::CORE, std::cout, "1 + 1 = %d", 2);

    return 0;
}

Output:

Core/A/../../../Samples/Main.cpp/main/line:5 :    1 + 1 = 2