+/**
+ * Register a user log function.
+ *
+ * @param usr_log
+ * Function pointer that will be invoked for each log call.
+ * If the parameter is NULL, ec_log_default_cb() is used.
+ * @param opaque
+ * Opaque pointer passed to the log function.
+ * @return
+ * 0 on success, -1 on error (errno is set).
+ */
+int ec_log_fct_register(ec_log_t usr_log, void *opaque);
+
+/**
+ * Register a named log type.
+ *
+ * Register a new log type, which is identified by its name. The
+ * function returns a log identifier associated to the log name. If the
+ * name is already registered, the function just returns its identifier.
+ *
+ * @param name
+ * The name of the log type.
+ * @return
+ * The log type identifier on success (positive or zero), -1 on
+ * error (errno is set).
+ */
+int ec_log_type_register(const char *name);
+
+/**
+ * Return the log name associated to the log type identifier.
+ *
+ * @param type
+ * The log type identifier.
+ * @return
+ * The name associated to the log type, or "unknown". It always return
+ * a valid string (never NULL).
+ */
+const char *ec_log_name(int type);
+
+/**
+ * Log a formatted string.
+ *
+ * @param type
+ * The log type identifier.
+ * @param level
+ * The log level.
+ * @param format
+ * The format string, followed by optional arguments.
+ * @return
+ * 0 on success, -1 on error (errno is set).
+ */
+int ec_log(int type, enum ec_log_level level, const char *format, ...)
+ __attribute__((format(__printf__, 3, 4)));
+
+/**
+ * Log a formatted string.
+ *
+ * @param type
+ * The log type identifier.
+ * @param level
+ * The log level.
+ * @param format
+ * The format string.
+ * @param ap
+ * The list of arguments.
+ * @return
+ * 0 on success, -1 on error (errno is set).
+ */
+int ec_vlog(int type, enum ec_log_level level, const char *format, va_list ap);
+
+/**
+ * Log a formatted string using the local log type.
+ *
+ * This macro requires that a log type is previously register with
+ * EC_LOG_TYPE_REGISTER() since it uses the "ec_log_local_type"
+ * variable.
+ *
+ * @param level
+ * The log level.
+ * @param format
+ * The format string, followed by optional arguments.
+ * @return
+ * 0 on success, -1 on error (errno is set).
+ */
+#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 register with
+ * EC_LOG_TYPE_REGISTER() since it uses the "ec_log_local_type"
+ * variable.
+ *
+ * @param level
+ * The log level.
+ * @param format
+ * The format string.
+ * @param ap
+ * The list of arguments.
+ * @return
+ * 0 on success, -1 on error (errno is set).
+ */
+#define EC_VLOG(level, fmt, ap) ec_vlog(ec_log_local_type, level, fmt, ap)
+
+/**
+ * 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().
+ *
+ * @param type
+ * The log type identifier.
+ * @param level
+ * The log level.
+ * @param opaque
+ * Unused.
+ * @param str
+ * The string to be logged.
+ * @return
+ * 0 on success, -1 on error (errno is set).
+ */
+int ec_log_default_cb(int type, enum ec_log_level level, void *opaque,
+ const char *str);
+
+/**
+ * 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.
+ *
+ * It is advised
+ *
+ * @param level
+ * The log level to be set.
+ * @return
+ * 0 on success, -1 on error.
+ */
+int ec_log_level_set(enum ec_log_level level);
+
+/**
+ * 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.
+ *
+ * @param level
+ * The log level to be set.
+ * @return
+ * 0 on success, -1 on error.
+ */
+enum ec_log_level ec_log_level_get(void);