ecoli_log(3)

πŸ“¦
version 0.11.3 Β· 4 versions
, in epel 9

πŸ’– 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 unusable
  • EC_LOG_ALERT β€” action must be taken immediately
  • EC_LOG_CRIT β€” critical conditions
  • EC_LOG_ERR β€” error conditions
  • EC_LOG_WARNING β€” warning conditions
  • EC_LOG_NOTICE β€” normal but significant condition
  • EC_LOG_INFO β€” informational
  • EC_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