CG_Labs  2021.2
Namespaces | Macros | Enumerations | Functions
Log.h File Reference
#include "BuildSettings.h"
#include <cstddef>
#include <cstdarg>

Go to the source code of this file.

Namespaces

 Log
 

Macros

#define SUCCESS(r)   ((r) == RESULT_SUCCESS)
 
#define FAILURE(r)   (!SUCCESS(r))
 
#define Assert(m)   if (!(static_cast<unsigned int>(m))) Log::Report(0, __FILE__, __FUNCTION__, __LINE__, Log::Type::TYPE_ASSERT, "Assertion failed at line %u in file %s.", __LINE__, __FILE__)
 
#define Param(m)   Log::ReportParam(static_cast<unsigned int>(m), __FILE__, __FUNCTION__, __LINE__)
 
#define LOG_MESSAGE_ONCE_FLAG   1
 
#define LOG_LOCATION_ONCE_FLAG   2
 
#define LOG_OUT_STD   (1 << 0)
 
#define LOG_OUT_FILE   (1 << 1)
 
#define LOG_OUT_CUSTOM   (1 << 15)
 
#define Log(m, ...)   Log::Report(0, __FILE__, __FUNCTION__, __LINE__, Log::Type::TYPE_NEUTRAL, static_cast<char const*>(m), ##__VA_ARGS__)
 
#define LogType(t, m, ...)   Log::Report(0, __FILE__, __FUNCTION__, __LINE__, t, static_cast<char const*>(m), ##__VA_ARGS__)
 
#define LogMsgOnce(t, m, ...)   Log::Report(LOG_MESSAGE_ONCE_FLAG, __FILE__, __FUNCTION__, __LINE__, t, static_cast<char const*>(m), ##__VA_ARGS__)
 
#define LogLocOnce(t, m, ...)   Log::Report(LOG_LOCATION_ONCE_FLAG, __FILE__, __FUNCTION__, __LINE__, t, static_cast<char const*>(m), ##__VA_ARGS__)
 
#define LogWarning(m, ...)   Log::Report(0, __FILE__, __FUNCTION__, __LINE__, Log::Type::TYPE_WARNING, static_cast<char const*>(m), ##__VA_ARGS__)
 
#define LogError(m, ...)   Log::Report(0, __FILE__, __FUNCTION__, __LINE__, Log::Type::TYPE_ERROR, static_cast<char const*>(m), ##__VA_ARGS__)
 
#define LogFile(m, ...)   Log::Report(0, __FILE__, __FUNCTION__, __LINE__, Log::Type::TYPE_FILE, static_cast<char const*>(m), ##__VA_ARGS__)
 
#define LogInfo(m, ...)   Log::Report(0, __FILE__, __FUNCTION__, __LINE__, Log::Type::TYPE_INFO, static_cast<char const*>(m), ##__VA_ARGS__)
 
#define LogTrivia(m, ...)   Log::Report(0, __FILE__, __FUNCTION__, __LINE__, Log::Type::TYPE_TRIVIA, static_cast<char const*>(m), ##__VA_ARGS__)
 

Enumerations

enum  Log::Type {
  Log::TYPE_SUCCESS = 0 , Log::TYPE_INFO = 1 , Log::TYPE_NEUTRAL = 2 , Log::TYPE_WARNING = 3 ,
  Log::TYPE_ERROR = 4 , Log::TYPE_FILE = 5 , Log::TYPE_ASSERT = 6 , Log::TYPE_PARAM = 7 ,
  Log::TYPE_TRIVIA = 8 , Log::N_TYPES = 9
}
 
enum  Log::Severity { Log::OK = 0 , Log::BAD , Log::TERMINAL }
 
enum  Log::Verbosity { Log::WHISPER = 0 , Log::LOUD_UNSITUATED , Log::LOUD }
 

Functions

void Log::Init ()
 
void Log::Destroy ()
 
void Log::SetCustomOutputTargetFunc (void(*textout)(Type, const char *))
 
void Log::SetOutputTargets (std::size_t targets)
 
void Log::SetVerbosity (Type type, Verbosity verbosity)
 
void Log::SetIncludeThreadID (bool inc)
 
void Log::Report (unsigned int flags, const char *file, const char *function, int line, Type type, const char *str,...)
 
bool Log::ReportParam (unsigned int test, const char *file, const char *function, int line)
 

Macro Definition Documentation

◆ Assert

#define Assert (   m)    if (!(static_cast<unsigned int>(m))) Log::Report(0, __FILE__, __FUNCTION__, __LINE__, Log::Type::TYPE_ASSERT, "Assertion failed at line %u in file %s.", __LINE__, __FILE__)

◆ FAILURE

#define FAILURE (   r)    (!SUCCESS(r))

◆ Log

#define Log (   m,
  ... 
)    Log::Report(0, __FILE__, __FUNCTION__, __LINE__, Log::Type::TYPE_NEUTRAL, static_cast<char const*>(m), ##__VA_ARGS__)

◆ LOG_LOCATION_ONCE_FLAG

#define LOG_LOCATION_ONCE_FLAG   2

◆ LOG_MESSAGE_ONCE_FLAG

#define LOG_MESSAGE_ONCE_FLAG   1

◆ LOG_OUT_CUSTOM

#define LOG_OUT_CUSTOM   (1 << 15)

◆ LOG_OUT_FILE

#define LOG_OUT_FILE   (1 << 1)

◆ LOG_OUT_STD

#define LOG_OUT_STD   (1 << 0)

◆ LogError

#define LogError (   m,
  ... 
)    Log::Report(0, __FILE__, __FUNCTION__, __LINE__, Log::Type::TYPE_ERROR, static_cast<char const*>(m), ##__VA_ARGS__)

◆ LogFile

#define LogFile (   m,
  ... 
)    Log::Report(0, __FILE__, __FUNCTION__, __LINE__, Log::Type::TYPE_FILE, static_cast<char const*>(m), ##__VA_ARGS__)

◆ LogInfo

#define LogInfo (   m,
  ... 
)    Log::Report(0, __FILE__, __FUNCTION__, __LINE__, Log::Type::TYPE_INFO, static_cast<char const*>(m), ##__VA_ARGS__)

◆ LogLocOnce

#define LogLocOnce (   t,
  m,
  ... 
)    Log::Report(LOG_LOCATION_ONCE_FLAG, __FILE__, __FUNCTION__, __LINE__, t, static_cast<char const*>(m), ##__VA_ARGS__)

◆ LogMsgOnce

#define LogMsgOnce (   t,
  m,
  ... 
)    Log::Report(LOG_MESSAGE_ONCE_FLAG, __FILE__, __FUNCTION__, __LINE__, t, static_cast<char const*>(m), ##__VA_ARGS__)

◆ LogTrivia

#define LogTrivia (   m,
  ... 
)    Log::Report(0, __FILE__, __FUNCTION__, __LINE__, Log::Type::TYPE_TRIVIA, static_cast<char const*>(m), ##__VA_ARGS__)

◆ LogType

#define LogType (   t,
  m,
  ... 
)    Log::Report(0, __FILE__, __FUNCTION__, __LINE__, t, static_cast<char const*>(m), ##__VA_ARGS__)

◆ LogWarning

#define LogWarning (   m,
  ... 
)    Log::Report(0, __FILE__, __FUNCTION__, __LINE__, Log::Type::TYPE_WARNING, static_cast<char const*>(m), ##__VA_ARGS__)

◆ Param

#define Param (   m)    Log::ReportParam(static_cast<unsigned int>(m), __FILE__, __FUNCTION__, __LINE__)

◆ SUCCESS

#define SUCCESS (   r)    ((r) == RESULT_SUCCESS)