NNG_LOG_SET_LOGGER(3)
π NNG_LOG_SET_LOGGER(3) π
okay bestie, welcome to the NNG Reference Manual β this is the page for nng_log_set_logger, and it's literally the one that decides who gets to hear the tea when your library wants to say something. let's get into it π«Ά
β¨ NAME β¨
nng_log_set_logger β set logging handler π
πΈ SYNOPSIS πΈ
#include <nng/nng.h>
typedef void (*nng_logger)(nng_log_level level, nng_log_facility facility,
const char *msgid, const char *msg);
void nng_null_logger(nng_log_level, nng_log_facility, const char *, const char *);
void nng_stderr_logger(nng_log_level, nng_log_facility, const char *, const char *);
void nng_system_logger(nng_log_level, nng_log_facility, const char *, const char *);
void nng_log_set_logger(nng_logger logger);
no cap, that typedef is the whole personality of this function. everything's a void *β¦ okay not literally, but the vibe is you pass a function pointer, I'll call it. π
π¦ DESCRIPTION π¦
so nng_log_set_logger does exactly one thing and it does it slay: it sets the base logging function to logger. that logger can totally be a function you wrote yourself, if you wanna process log messages your own way. main character behavior, honestly. π
But β and this is the important part β only one logger may be registered at a time. one. singular. there is no polycule of loggers here. π
π¨ bestie listen up: if your logger is gonna hold ontomsgidormsgpast the moment it returns, it must make copies of them first. those strings may not be valid once your logger function returns. like, they could be gone-gone. copy them or cry about it. π
π The built-in loggers π
okay so NNG ships with three ready-made logger implementations so you don't have to write your own from scratch. obsessed with the convenience, honestly.
nng_null_loggerβ the "I'm on Do Not Disturb" logger. it's an implementation ofnng_loggerthat simply discards the content. nothing gets logged, nothing gets said, the vibes stay immaculate and silent. this is the default logger, which means logging is disabled by default. you literally have to opt in to hearing anything. iconic hermit energy. πnng_stderr_loggerβ the chatty one. it's an implementation that logs messages to the standard error stream. and the way it will attempt to colorize messages by the severity if standard error is a terminal device?? actual aesthetic. πβ¨
but if you're not in the mood for the rainbow, you can suppress it by setting either the NO_COLOR or the NNG_LOG_NO_COLOR environment variables. either one works, pick your fighter. π
nng_system_loggerβ the one that plays nicely with your OS. it attempts to use an appropriate system facility to log messages. on POSIX systems, that means it usessyslogto process the messages. for other systems,nng_stderr_logmay be used as a fallback. so like, if it can't find the system's vibe, it'll just use the stderr vibe. versatile king. π
π SEE ALSO π
the friend group, the squad, the trio:
π that's the whole page, bestie π
and that's a wrap fr fr. this page came from the NNG Reference Manual and it's dated 2026-06-30, so you know it's fresh. periodt. π β¨πΈπ¦ππ«Ά
NNG_LOG_SET_LOGGER(3) β go set that logger, you got this. π₯π
π¦ where this page comes from
- ubuntu stonking: libnng-dev 1.12.0-1 Β· MIT OR Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms