ecoli_log(3)
π NAME π
ecoli_log - Log. π
Also β- Log API.β literally. This is the ecoli_log(3) page from Libecoli, and itβs all about the Log API, no cap.
πΈ SYNOPSIS πΈ
π Data Structures
struct ec_log_type
π Macros
#define EC_LOG_TYPE_REGISTER(name)#define EC_LOG(level, args...) ec_log(ec_log_local_type, level, args)#define EC_VLOG(level, fmt, ap) ec_vlog(ec_log_local_type, level, fmt, ap)
π Typedefs
typedef int(* ec_log_t) (int type, enum ec_log_level level, void *opaque, const char *str)
π Enumerations
enum ec_log_level { EC_LOG_EMERG = 0, EC_LOG_ALERT = 1, EC_LOG_CRIT = 2,
EC_LOG_ERR = 3, EC_LOG_WARNING = 4, EC_LOG_NOTICE = 5, EC_LOG_INFO =
6, EC_LOG_DEBUG = 7 }
π Functions
int ec_log_fct_register (ec_log_t usr_log, void *opaque)
int ec_log_type_register (struct ec_log_type *type)
const char * ec_log_name (int type)
int ec_log (int type, enum ec_log_level level, const char *format,...)
__attribute__((format(__printf__
int int ec_vlog (int type, enum ec_log_level level, const char *format,
va_list ap)
int ec_log_default_cb (int type, enum ec_log_level level, void *opaque,
const char *str)
int ec_log_level_set (enum ec_log_level level)
enum ec_log_level ec_log_level_get (void)
π¦ Detailed Description π¦
Log API. π
This file provides logging helpers:
- logging functions, supporting printf-like format
- several debug levels (similar to syslog)
- named log types
- redirection of logs to user functions (default logs nothing)
π Macro Definition Documentation π
π
#define EC_LOG_TYPE_REGISTER(name)
Value:
static struct ec_log_type name##_log_type = { .n##ame = #name, }; static int ec_log_local_type; __attribute__((constructor, used)) static void ec_log_register_##name(void) { ec_log_local_type = ec_log_type_register(&name##_log_type); ec_assert_print(ec_log_local_type >= 0, "cannot register log type.0); }
Okay so this macro registers a log type, bestie. π
It defines a function that will be called at startup (using the 'constructor' attribute). This function registers the named type passed as argument, and sets a static global variable ec_log_local_type. This variable is used as the default log type for this file when using EC_LOG() or EC_VLOG(). π«Ά
This macro can be present several times in a file. In this case, the local log type is set to the last registered type. Not me keeping track of the last one π
On error, the function aborts. π¨
Parameters
- name β The name of the log to be registered.
Definition at line 69 of file log.h.
π
#define EC_LOG(level, args...) ec_log(ec_log_local_type, level, args)
Log a formatted string using the local log type. β¨
This macro requires that a log type is previously registered with EC_LOG_TYPE_REGISTER() since it uses the ec_log_local_type variable.
Parameters
- level β The log level.
- args β The format string, followed by optional arguments.
Returns 0 on success, -1 on error (errno is set).
Definition at line 184 of file log.h.
π
#define EC_VLOG(level, fmt, ap) ec_vlog(ec_log_local_type, level, fmt, ap)
Log a formatted string using the local log type. π¦
This macro requires that a log type is previously registered with EC_LOG_TYPE_REGISTER() since it uses the ec_log_local_type variable.
Parameters
- level β The log level.
- fmt β The format string.
- ap β The list of arguments.
Returns 0 on success, -1 on error (errno is set).
Definition at line 202 of file log.h.
π§ Typedef Documentation π§
π typedef int(* ec_log_t) (int type, enum ec_log_level level, void *opaque, const char *str)
User log function type. β¨
It is advised that a user-defined log function drops all messages that are less critical than ec_log_level_get(), as done by the default handler. Like, vibe check your logs, bestie π
Parameters
- type β The log type identifier.
- level β The log level.
- opaque β The opaque pointer that was passed to
ec_log_fct_register(). - str β The string to log.
Returns 0 on success, -1 on error (errno is set).
Definition at line 98 of file log.h.
π Enumeration Type Documentation π
π enum ec_log_level
Log levels, from most critical to least critical. ππ₯
Enumerator
EC_LOG_EMERGβ system is unusableEC_LOG_ALERTβ action must be taken immediatelyEC_LOG_CRITβ critical conditionsEC_LOG_ERRβ error conditionsEC_LOG_WARNINGβ warning conditionsEC_LOG_NOTICEβ normal but significant conditionEC_LOG_INFOβ informationalEC_LOG_DEBUGβ debug-level messages
Definition at line 29 of file log.h.
π Function Documentation π
π«Ά ec_log_fct_register
int ec_log_fct_register (ec_log_t usr_log, void * opaque)
Register a user log function. β¨
Parameters
- usr_log β Function pointer that will be invoked for each log call. If the parameter is
NULL,ec_log_default_cb()is used. - opaque β Opaque pointer passed to the log function.
Returns 0 on success, -1 on error (errno is set).
π«Ά ec_log_type_register
int ec_log_type_register (struct ec_log_type * type)
Register a named log type. π
Register a new log type, which is identified by its name. The function returns a log identifier associated with the log name. If the name is already registered, the function just returns its identifier.
Parameters
- type β The log type to register.
Returns The log type identifier on success (positive or zero), -1 on error (errno is set).
π«Ά ec_log_name
const char* ec_log_name (int type)
Return the log name associated with the log type identifier. β¨
Parameters
- type β The log type identifier.
Returns The name associated with the log type, or 'unknown'. It always returns a valid string (never NULL). Never NULL, periodt.
π«Ά ec_log
int ec_log (int type, enum ec_log_level level, const char * format, ...)
Log a formatted string. π
Parameters
- type β The log type identifier.
- level β The log level.
- format β The format string, followed by optional arguments.
Returns 0 on success, -1 on error (errno is set).
π«Ά ec_vlog
int int ec_vlog (int type, enum ec_log_level level, const char * format,
va_list ap)
Log a formatted string. π¦
Parameters
- type β The log type identifier.
- level β The log level.
- format β The format string.
- ap β The list of arguments.
Returns 0 on success, -1 on error (errno is set).
π«Ά ec_log_default_cb
int ec_log_default_cb (int type, enum ec_log_level level, void * opaque,
const char * str)
Default log handler. π
This is the default log function that is used by the library. By default, it prints all logs whose level is WARNING or more critical. This level can be changed with ec_log_level_set().
Parameters
- type β The log type identifier.
- level β The log level.
- opaque β Unused.
- str β The string to be logged.
Returns 0 on success, -1 on error (errno is set).
π«Ά ec_log_level_set
int ec_log_level_set (enum ec_log_level level)
Set the global log level. ποΈ
This level is used by the default log handler, ec_log_default_cb(). All messages that are at least as critical as the default level are displayed.
Parameters
- level β The log level to be set.
Returns 0 on success, -1 on error.
π«Ά ec_log_level_get
enum ec_log_level ec_log_level_get (void)
Get the global log level. β¨
This level is used by the default log handler, ec_log_default_cb(). All messages that are at least as critical as the default level are displayed.
Returns The current global log level
π¦ Author π¦
Generated automatically by Doxygen for Libecoli from the source code. π«Ά Doxygen really said βIβll write the docs for you, bestieβ and slayed.
Thatβs the whole ecoli_log(3) glow-up, bestie. This iconic page is from Libecoli, version 0.11.3, dated Thu Apr 9 2026. Bye for now β go log something iconic! π
β¨
π¦ where this page comes from
- epel 9: libecoli-devel 0.11.3-1.el9 Β· BSD-3-Clause AND LicenseRef-Fedora-Public-Domain
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms