libonion
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions | Variables
Log. Functions to ease logging and debugging in onion programs

Macros

#define ONION_DEBUG(...)
 Logs a debug information. When compiled in release mode this is not compiled.
#define ONION_DEBUG0(...)
 Logs a lower debug information. When compiled in release mode this is not compiledTo use it, an environmetal variable ONION_DEBUG0=filename.c is required. If not present it shows nothing.
#define ONION_INFO(...)   onion_log(O_INFO, __FILE__, __LINE__, __VA_ARGS__)
 Logs some information.
#define ONION_WARNING(...)   onion_log(O_WARNING, __FILE__, __LINE__, __VA_ARGS__)
 Logs some warning.
#define ONION_ERROR(...)   onion_log(O_ERROR, __FILE__, __LINE__, __VA_ARGS__)
 Logs some error.

Functions

void onion_log_stderr (onion_log_level level, const char *filename, int lineno, const char *fmt,...)
 Logs to stderr.It can be affected also by the environment variable ONION_LOG, with one or several of:
void onion_log_syslog (onion_log_level level, const char *filename, int lineno, const char *fmt,...)
 Performs the log to the syslog.

Variables

void(* onion_log )(onion_log_level level, const char *filename, int lineno, const char *fmt,...) = onion_log_stderr
 Logs a message to the log facility.Normally to stderr, but can be set to your own logger or to use syslog.

Detailed Description

Macro Definition Documentation

#define ONION_DEBUG (   ...)

Logs a debug information. When compiled in release mode this is not compiled.

Referenced by authorize(), onion_add_listen_point(), onion_dict_from_json(), onion_free(), onion_handler_path_handler(), onion_https_t::onion_https_close(), onion_https_t::onion_https_free_user_data(), onion_https_t::onion_https_listen_stop(), onion_https_t::onion_https_new(), onion_https_t::onion_https_read(), onion_https_t::onion_https_request_init(), onion_https_t::onion_https_set_certificate_argv(), onion_https_t::onion_https_write(), onion_json_unquote_add(), onion_listen(), onion_listen_point_t::onion_listen_point_free(), onion_listen_point_t::onion_listen_point_listen(), onion_listen_point_t::onion_listen_point_request_init_from_socket(), onion_listen_stop(), onion_new(), onion_poller_t::onion_poller_free(), onion_poller_t::onion_poller_new(), onion_poller_t::onion_poller_poll(), onion_poller_t::onion_poller_stop(), onion_request_t::onion_request_guess_session_id(), onion_request_t::onion_request_new(), onion_request_t::onion_request_session_free(), onion_response_add_cookie(), onion_response_t::onion_response_new(), onion_response_t::onion_response_write(), onion_root_url(), onion_sessions_t::onion_sessions_create(), onion_set_certificate_va(), onion_shortcut_response_file(), onion_url_handler(), onion_version_is_compatible3(), onion_webdav_delete(), onion_webdav_get(), onion_webdav_handler(), onion_webdav_move(), onion_webdav_propfind(), onion_webdav_proppatch(), onion_webdav_put(), onion_webdav_write_propfind(), onion_webdav_write_props(), onion_websocket_t::onion_websocket_call(), onion_websocket_t::onion_websocket_new(), onion_websocket_t::onion_websocket_read(), onion_websocket_t::onion_websocket_write(), and token_read_LINE().

#define ONION_DEBUG0 (   ...)
#define ONION_ERROR (   ...)    onion_log(O_ERROR, __FILE__, __LINE__, __VA_ARGS__)

Logs some error.

Referenced by authorize(), onion_add_listen_point(), onion_dict_t::onion_dict_add(), onion_error_exit(), onion_handler_export_local_handler(), onion_handler_export_local_new(), onion_handler_t::onion_handler_handle(), onion_https_t::onion_https_new(), onion_https_t::onion_https_read(), onion_https_t::onion_https_request_init(), onion_https_t::onion_https_set_certificate_argv(), onion_listen(), onion_listen_point_t::onion_listen_point_accept(), onion_listen_point_t::onion_listen_point_listen(), onion_listen_point_t::onion_listen_point_read_ready(), onion_listen_point_t::onion_listen_point_request_init_from_socket(), onion_poller_t::onion_poller_add(), onion_poller_get(), onion_poller_t::onion_poller_new(), onion_poller_t::onion_poller_poll(), onion_poller_remove(), onion_poller_t::onion_poller_remove(), onion_poller_slot_t::onion_poller_slot_new(), onion_poller_t::onion_poller_stop(), onion_random_init(), onion_response_flush(), onion_response_t::onion_response_vprintf(), onion_response_t::onion_response_write_headers(), onion_sessions_redis_new(), onion_sessions_redis_save(), onion_sessions_sqlite3_new(), onion_sessions_sqlite3_save(), onion_set_certificate_va(), onion_sha1(), onion_shortcut_rename(), onion_shortcut_response_file(), onion_url_add_handler(), onion_webdav_default_check_permissions(), onion_webdav_delete(), onion_webdav_move(), onion_webdav_propfind(), onion_webdav_put(), onion_webdav_write_propfind(), onion_webdav_write_props(), onion_websocket_t::onion_websocket_call(), onion_websocket_t::onion_websocket_new(), onion_websocket_t::onion_websocket_read(), onion_websocket_t::onion_websocket_vprintf(), token_read_KEY(), token_read_MULTIPART_BOUNDARY(), token_read_STRING(), and token_read_until().

#define ONION_INFO (   ...)    onion_log(O_INFO, __FILE__, __LINE__, __VA_ARGS__)

Logs some information.

Referenced by onion_response_t::onion_response_free(), and onion_webdav_move().

#define ONION_WARNING (   ...)    onion_log(O_WARNING, __FILE__, __LINE__, __VA_ARGS__)

Function Documentation

void onion_log_stderr ( onion_log_level  level,
const char *  filename,
int  lineno,
const char *  fmt,
  ... 
)

Logs to stderr.It can be affected also by the environment variable ONION_LOG, with one or several of:

  • "nocolor" – then output will be without colors.
  • "syslog" – Switchs the logging to syslog.
  • "noinfo" – Do not show info lines.
  • "nodebug" – When in debug mode, do not show debug lines.

Also for DEBUG0 level, it must be explictly set with the environmental variable ONION_DEBUG0, set to the names of the files to allow DEBUG0 debug info. For example:

export ONION_DEBUG0="onion.c url.c"

It is thread safe.

When compiled in release mode (no DEBUG defined), DEBUG and DEBUG0 are not compiled so they do not incurr in any performance penalty.

References O_DEBUG, O_DEBUG0, O_INFO, OF_NOCOLOR, OF_NODEBUG, OF_NOINFO, and onion_log_flags.

void onion_log_syslog ( onion_log_level  level,
const char *  filename,
int  lineno,
const char *  fmt,
  ... 
)

Performs the log to the syslog.

Variable Documentation

void(* onion_log)(onion_log_level level, const char *filename, int lineno, const char *fmt,...) = onion_log_stderr

Logs a message to the log facility.Normally to stderr, but can be set to your own logger or to use syslog.

This function can be overwritten with whatever onion_log facility you want to use, same signature.

It is actually a variable which you can set to any other log facility. By default it is to onion_log_stderr, but also available is onion_log_syslog.

Parameters
levelLevel of log.
filenameFile where the message appeared. Usefull on debug level, but available on all.
linenoLine where the message was produced.
fmtprintf-like format string and parameters.