NkFoundationLog.h
#include "NKPlatform/NkFoundationLog.h"nkentseu::platformnkentseudependson(["NKPlatform"])Functions · 2
NkFoundationSetLogSink | Sets a custom log sink |
NkFoundationGetLogSink | Gets the log sink currently configured |
Aliases · 1
NkFoundationLogSink | Function type for the custom log sink |
Variables · 1
gNkFoundationLogSink | Global log sink configured by the user |
Macros · 21
NK_FOUNDATION_HAS_ANDROID_LOG | Flag for Android Log availability |
NK_FOUNDATION_RESTORE_LOGGER_MACRO | Defined, with no value, when a « logger » macro already existed: it is restored at the end of the header. |
NK_FOUNDATION_LOG_LEVEL_NONE | Log level: no log |
NK_FOUNDATION_LOG_LEVEL_ERROR | Log level: critical errors |
NK_FOUNDATION_LOG_LEVEL_WARN | Log level: warnings |
NK_FOUNDATION_LOG_LEVEL_INFO | Log level: general information |
NK_FOUNDATION_LOG_LEVEL_DEBUG | Log level: debug messages |
NK_FOUNDATION_LOG_LEVEL_TRACE | Log level: detailed traces (very verbose) |
NK_FOUNDATION_LOG_LEVEL | Log level active at compile time |
NK_FOUNDATION_PRINT | Generic log macro (INFO level) |
NK_FOUNDATION_SPRINT | Safe sprintf-style formatting macro |
NK_FOUNDATION_LOG_ERROR | ERROR level log macro |
NK_FOUNDATION_LOG_WARN | WARN level log macro |
NK_FOUNDATION_LOG_INFO | INFO level log macro |
NK_FOUNDATION_LOG_DEBUG | DEBUG level log macro |
NK_FOUNDATION_LOG_TRACE | TRACE level log macro |
NK_FOUNDATION_LOG_ERROR_VALUE | ERROR level log macro for a labelled value |
NK_FOUNDATION_LOG_WARN_VALUE | WARN level log macro for a labelled value |
NK_FOUNDATION_LOG_INFO_VALUE | INFO level log macro for a labelled value |
NK_FOUNDATION_LOG_DEBUG_VALUE | DEBUG level log macro for a labelled value |
NK_FOUNDATION_LOG_TRACE_VALUE | TRACE level log macro for a labelled value |
Member details
Flag for Android Log availability
Defined, with no value, when a « logger » macro already existed: it is restored at the end of the header.
Log level: no log
Log level: critical errors
Log level: warnings
Log level: general information
Log level: debug messages
Log level: detailed traces (very verbose)
Log level active at compile time
#define NK_FOUNDATION_LOG_LEVEL NK_FOUNDATION_LOG_LEVEL_TRACE #include "NKPlatform/NkFoundationLog.h"
Function type for the custom log sink
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);
Global log sink configured by the user
Sets a custom log sink
Parameters
| Name | Type | Role | Default |
|---|---|---|---|
sink | NkFoundationLogSink |
// Définir un sink personnalisé au démarrage de l'application NkFoundationSetLogSink(MyFileLogger); // Réinitialiser vers le backend par défaut NkFoundationSetLogSink(nullptr);
Gets the log sink currently configured
Generic log macro (INFO level)
NK_FOUNDATION_PRINT("Initialisation de la bibliothèque v%d.%d", 1, 2);
Safe sprintf-style formatting macro
ERROR level log macro
if (!file.Open("config.ini")) { NK_FOUNDATION_LOG_ERROR("Échec d'ouverture: %s", file.GetLastError()); return false; }
WARN level log macro
INFO level log macro
DEBUG level log macro
TRACE level log macro
ERROR level log macro for a labelled value
NK_FOUNDATION_LOG_ERROR_VALUE("errorCode", result); // Sortie : [ERR] myfile.cpp:42 errorCode=-1
WARN level log macro for a labelled value
INFO level log macro for a labelled value
DEBUG level log macro for a labelled value
TRACE level log macro for a labelled value