Rihen Rihen NkentseuDocumentation

NkFoundationLog.h

Include
#include "NKPlatform/NkFoundationLog.h"
Namespace
nkentseu::platform
Link (Jenga)
nkentseudependson(["NKPlatform"])

Functions · 2

NkFoundationSetLogSinkSets a custom log sink
NkFoundationGetLogSinkGets the log sink currently configured

Aliases · 1

NkFoundationLogSinkFunction type for the custom log sink

Variables · 1

gNkFoundationLogSinkGlobal log sink configured by the user

Macros · 21

NK_FOUNDATION_HAS_ANDROID_LOGFlag for Android Log availability
NK_FOUNDATION_RESTORE_LOGGER_MACRO
NK_FOUNDATION_LOG_LEVEL_NONELog level: no log
NK_FOUNDATION_LOG_LEVEL_ERRORLog level: critical errors
NK_FOUNDATION_LOG_LEVEL_WARNLog level: warnings
NK_FOUNDATION_LOG_LEVEL_INFOLog level: general information
NK_FOUNDATION_LOG_LEVEL_DEBUGLog level: debug messages
NK_FOUNDATION_LOG_LEVEL_TRACELog level: detailed traces (very verbose)
NK_FOUNDATION_LOG_LEVELLog level active at compile time
NK_FOUNDATION_PRINTGeneric log macro (INFO level)
NK_FOUNDATION_SPRINTSafe sprintf-style formatting macro
NK_FOUNDATION_LOG_ERRORERROR level log macro
NK_FOUNDATION_LOG_WARNWARN level log macro
NK_FOUNDATION_LOG_INFOINFO level log macro
NK_FOUNDATION_LOG_DEBUGDEBUG level log macro
NK_FOUNDATION_LOG_TRACETRACE level log macro
NK_FOUNDATION_LOG_ERROR_VALUEERROR level log macro for a labelled value
NK_FOUNDATION_LOG_WARN_VALUEWARN level log macro for a labelled value
NK_FOUNDATION_LOG_INFO_VALUEINFO level log macro for a labelled value
NK_FOUNDATION_LOG_DEBUG_VALUEDEBUG level log macro for a labelled value
NK_FOUNDATION_LOG_TRACE_VALUETRACE level log macro for a labelled value

Member details

NK_FOUNDATION_HAS_ANDROID_LOG

#
macro
#define NK_FOUNDATION_HAS_ANDROID_LOG

Flag for Android Log availability

NK_FOUNDATION_RESTORE_LOGGER_MACRO

#
macro
#define NK_FOUNDATION_RESTORE_LOGGER_MACRO

NK_FOUNDATION_LOG_LEVEL_NONE

#
macro
#define NK_FOUNDATION_LOG_LEVEL_NONE

Log level: no log

NK_FOUNDATION_LOG_LEVEL_ERROR

#
macro
#define NK_FOUNDATION_LOG_LEVEL_ERROR

Log level: critical errors

NK_FOUNDATION_LOG_LEVEL_WARN

#
macro
#define NK_FOUNDATION_LOG_LEVEL_WARN

Log level: warnings

NK_FOUNDATION_LOG_LEVEL_INFO

#
macro
#define NK_FOUNDATION_LOG_LEVEL_INFO

Log level: general information

NK_FOUNDATION_LOG_LEVEL_DEBUG

#
macro
#define NK_FOUNDATION_LOG_LEVEL_DEBUG

Log level: debug messages

NK_FOUNDATION_LOG_LEVEL_TRACE

#
macro
#define NK_FOUNDATION_LOG_LEVEL_TRACE

Log level: detailed traces (very verbose)

NK_FOUNDATION_LOG_LEVEL

#
macro
#define NK_FOUNDATION_LOG_LEVEL

Log level active at compile time

@codefragment, not compiled
#define NK_FOUNDATION_LOG_LEVEL NK_FOUNDATION_LOG_LEVEL_TRACE
#include "NKPlatform/NkFoundationLog.h"

NkFoundationLogSink

#
alias
using NkFoundationLogSink = void (*)(const char *level, const char *file, int line, const char *message)

Function type for the custom log sink

@codefragment, not compiled
void MyCustomSink(const char* level, const char* file, int line, const char* message) {
    // Envoyer vers un serveur de logs, écrire dans un fichier, etc.
    fprintf(myLogFile, "[%s] %s:%d %s\n", level, file, line, message);
}

NkFoundationSetLogSink(MyCustomSink);

gNkFoundationLogSink

#
variable
extern NkFoundationLogSink gNkFoundationLogSink

Global log sink configured by the user

NkFoundationSetLogSink

#
function
void NkFoundationSetLogSink(NkFoundationLogSink sink)

Sets a custom log sink

Parameters

NameTypeRoleDefault
sinkNkFoundationLogSink
@codefragment, not compiled
// Définir un sink personnalisé au démarrage de l'application
NkFoundationSetLogSink(MyFileLogger);

// Réinitialiser vers le backend par défaut
NkFoundationSetLogSink(nullptr);

NkFoundationGetLogSink

#
function
NkFoundationLogSink NkFoundationGetLogSink()

Gets the log sink currently configured

NK_FOUNDATION_PRINT

#
macro
#define NK_FOUNDATION_PRINT(fmt, ...)

Generic log macro (INFO level)

@codefragment, not compiled
NK_FOUNDATION_PRINT("Initialisation de la bibliothèque v%d.%d", 1, 2);

NK_FOUNDATION_SPRINT

#
macro
#define NK_FOUNDATION_SPRINT(buffer, bufferSize, fmt, ...)

Safe sprintf-style formatting macro

NK_FOUNDATION_LOG_ERROR

#
macro
#define NK_FOUNDATION_LOG_ERROR(fmt, ...)

ERROR level log macro

@codefragment, not compiled
if (!file.Open("config.ini")) {
    NK_FOUNDATION_LOG_ERROR("Échec d'ouverture: %s", file.GetLastError());
    return false;
}

NK_FOUNDATION_LOG_WARN

#
macro
#define NK_FOUNDATION_LOG_WARN(fmt, ...)

WARN level log macro

NK_FOUNDATION_LOG_INFO

#
macro
#define NK_FOUNDATION_LOG_INFO(fmt, ...)

INFO level log macro

NK_FOUNDATION_LOG_DEBUG

#
macro
#define NK_FOUNDATION_LOG_DEBUG(fmt, ...)

DEBUG level log macro

NK_FOUNDATION_LOG_TRACE

#
macro
#define NK_FOUNDATION_LOG_TRACE(fmt, ...)

TRACE level log macro

NK_FOUNDATION_LOG_ERROR_VALUE

#
macro
#define NK_FOUNDATION_LOG_ERROR_VALUE(label, value)

ERROR level log macro for a labelled value

@codefragment, not compiled
NK_FOUNDATION_LOG_ERROR_VALUE("errorCode", result);
// Sortie : [ERR] myfile.cpp:42 errorCode=-1

NK_FOUNDATION_LOG_WARN_VALUE

#
macro
#define NK_FOUNDATION_LOG_WARN_VALUE(label, value)

WARN level log macro for a labelled value

NK_FOUNDATION_LOG_INFO_VALUE

#
macro
#define NK_FOUNDATION_LOG_INFO_VALUE(label, value)

INFO level log macro for a labelled value

NK_FOUNDATION_LOG_DEBUG_VALUE

#
macro
#define NK_FOUNDATION_LOG_DEBUG_VALUE(label, value)

DEBUG level log macro for a labelled value

NK_FOUNDATION_LOG_TRACE_VALUE

#
macro
#define NK_FOUNDATION_LOG_TRACE_VALUE(label, value)

TRACE level log macro for a labelled value