Log
Eina » Tools

## Data Structures

struct | _Eina_Log_Domain
| The domain used for logging. More...

## Macros

#define | EINA_LOG_DOMAIN_DEFAULT EINA_LOG_DOMAIN_GLOBAL
| This macro defines the domain to use with the macros EINA_LOG_DOM_DBG(), EINA_LOG_DOM_INFO(), EINA_LOG_DOM_WARN(), EINA_LOG_DOM_ERR() and EINA_LOG_DOM_CRIT().
#define | EINA_LOG(DOM, LEVEL, fmt, ...)
| Logs a message on the specified domain, level and format.
#define | EINA_LOG_DOM_CRIT(DOM, fmt, ...)
| Logs a message with level CRITICAL on the specified domain and format.
#define | EINA_LOG_DOM_ERR(DOM, fmt, ...)
| Logs a message with level ERROR on the specified domain and format.
#define | EINA_LOG_DOM_INFO(DOM, fmt, ...)
| Logs a message with level INFO on the specified domain and format.
#define | EINA_LOG_DOM_DBG(DOM, fmt, ...)
| Logs a message with level DEBUG on the specified domain and format.
#define | EINA_LOG_DOM_WARN(DOM, fmt, ...)
| Logs a message with level WARN on the specified domain and format.
#define | EINA_LOG_CRIT(fmt, ...)
| Logs a message with level CRITICAL on the default domain with the specified format.
#define | EINA_LOG_ERR(fmt, ...)
| Logs a message with level ERROR on the default domain with the specified format.
#define | EINA_LOG_INFO(fmt, ...)
| Logs a message with level INFO on the default domain with the specified format.
#define | EINA_LOG_WARN(fmt, ...)
| Logs a message with level WARN on the default domain with the specified format.
#define | EINA_LOG_DBG(fmt, ...)
| Logs a message with level DEBUG on the default domain with the specified format.
#define | EINA_LOG_STATE_INIT _eina_log_state_init
| String that indicates the log system is initializing.
#define | EINA_LOG_STATE_SHUTDOWN _eina_log_state_shutdown
| String that indicates the log system is shutting down.

## Typedefs

typedef struct _Eina_Log_Domain | Eina_Log_Domain
| The domain used for logging.
typedef enum _Eina_Log_Level | Eina_Log_Level
| List of available logging levels.
typedef void(* | Eina_Log_Print_Cb) (const Eina_Log_Domain *d, Eina_Log_Level level, const char *file, const char *fnc, int line, const char *fmt, void *data, va_list args)
| Type for print callbacks.
typedef enum _Eina_Log_State | Eina_Log_State
| List of available log states.

## Enumerations

enum | _Eina_Log_Level { EINA_LOG_LEVEL_CRITICAL , EINA_LOG_LEVEL_ERR , EINA_LOG_LEVEL_WARN , EINA_LOG_LEVEL_INFO , EINA_LOG_LEVEL_DBG , EINA_LOG_LEVELS , EINA_LOG_LEVEL_UNKNOWN = (-2147483647 - 1) }
| List of available logging levels. More...
enum | _Eina_Log_State { EINA_LOG_STATE_START , EINA_LOG_STATE_STOP }
| List of available log states. More...

## Functions

static Eina_Bool | eina_log_level_check (int level)
| Checks whenever the given level should be printed out.
static Eina_Bool | eina_log_domain_level_check (int domain, int level)
| Checks whenever the given level should be printed out.
static const char * | eina_log_level_name_get (int level, char name[4])
| Function to format the level as a 3 character (+1 null byte) string.
static const char * | eina_log_level_color_get (int level)
| Function to get recommended color value for level.
static const char * | eina_log_level_color_if_enabled_get (int level)
| Function to get recommended color value for level, if colors are enabled.
EINA_API void | eina_log_threads_enable (void)
| Enable logging module to handle threads.
EINA_API void | eina_log_print_cb_set (Eina_Log_Print_Cb cb, void *data)
| Sets logging method to use.
EINA_API void | eina_log_level_set (int level)
| Sets the default log level.
EINA_API int | eina_log_level_get (void)
| Gets the default log level.
EINA_API Eina_Bool | eina_log_main_thread_check (void)
| Checks if current thread is the main thread.
EINA_API void | eina_log_color_disable_set (Eina_Bool disabled)
| Enables or disables colored text in the logs.
EINA_API Eina_Bool | eina_log_color_disable_get (void)
| Determines if color logging is enabled or disabled.
EINA_API void | eina_log_file_disable_set (Eina_Bool disabled)
| Sets if originating file name logging should be disabled.
EINA_API Eina_Bool | eina_log_file_disable_get (void)
| Gets if originating file name logging should be disabled.
EINA_API void | eina_log_function_disable_set (Eina_Bool disabled)
| Sets if originating function name logging should be disabled.
EINA_API Eina_Bool | eina_log_function_disable_get (void)
| Gets if originating function name logging should be disabled.
EINA_API void | eina_log_abort_on_critical_set (Eina_Bool abort_on_critical)
| Sets if critical messages should abort the program.
EINA_API Eina_Bool | eina_log_abort_on_critical_get (void)
| Gets if critical messages should abort the program.
EINA_API void | eina_log_abort_on_critical_level_set (int critical_level)
| Sets level that triggers abort if abort-on-critical is set.
EINA_API int | eina_log_abort_on_critical_level_get (void)
| Gets level that triggers abort if abort-on-critical is set.
EINA_API void | eina_log_domain_level_set (const char *domain_name, int level)
| Sets the domain level given its name.
EINA_API int | eina_log_domain_level_get (const char *domain_name)
| Gets the domain level given its name.
EINA_API int | eina_log_domain_registered_level_get (int domain)
| Gets the domain level given its identifier.
EINA_API void | eina_log_domain_registered_level_set (int domain, int level)
| Sets the domain level given its identifier.
EINA_API int | eina_log_domain_register (const char *name, const char *color)
EINA_API void | eina_log_domain_unregister (int domain)
| Forgets about a logging domain registered by eina_log_domain_register().
EINA_API void | eina_log_print (int domain, Eina_Log_Level level, const char *file, const char *function, int line, const char *fmt,...) EINA_PRINTF(6
| Prints out log message using given domain and level.
EINA_API void | eina_log_vprint (int domain, Eina_Log_Level level, const char *file, const char *fnc, int line, const char *fmt, va_list args) EINA_NOINSTRUMENT
| Prints out log message using given domain and level.
EINA_API void | eina_log_print_cb_stdout (const Eina_Log_Domain *d, Eina_Log_Level level, const char *file, const char *fnc, int line, const char *fmt, void *data, va_list args)
| Alternative logging method, this will output to standard output stream.
EINA_API void | eina_log_print_cb_stderr (const Eina_Log_Domain *d, Eina_Log_Level level, const char *file, const char *fnc, int line, const char *fmt, void *data, va_list args)
| Default logging method, this will output to standard error stream.
EINA_API void | eina_log_print_cb_file (const Eina_Log_Domain *d, Eina_Log_Level level, const char *file, const char *fnc, int line, const char *fmt, void *data, va_list args)
| Alternative logging method, this will output to given file stream.
EINA_API void | eina_log_print_cb_journald (const Eina_Log_Domain *d, Eina_Log_Level level, const char *file, const char *fnc, int line, const char *fmt, void *data, va_list args)
| Alternative logging method, this will output to systemd journal.
EINA_API void | eina_log_console_color_set (FILE *fp, const char *color)
| Configures console color of given file.
EINA_API void | eina_log_timing (int domain, Eina_Log_State state, const char *phase)
| Starts or stops the timing of a phase.

## Variables

EINA_API int | EINA_LOG_DOMAIN_GLOBAL
| EINA_LOG_DOMAIN_GLOBAL is the general purpose log domain to be used, it is always registered and available everywhere.
EINA_API void | EINA_NOINSTRUMENT
EINA_API const char * | _eina_log_state_init
| String that indicates the log system is initializing.
EINA_API const char * | _eina_log_state_shutdown
| String that indicates the log system is shutting down.

## Detailed Description

Full-featured logging system.

Eina provides eina_log_print(), a standard function to manage all logging messages. This function may be called directly or using the helper macros such as EINA_LOG_DBG(), EINA_LOG_ERR() or those that take a specific domain as argument EINA_LOG_DOM_DBG(), EINA_LOG_DOM_ERR(). Internally, eina_log_print() will call the function defined with eina_log_print_cb_set(), that defaults to eina_log_print_cb_stderr(), but may be changed to do whatever you need, such as networking or syslog logging.

The logging system is thread safe once initialized with eina_log_threads_enable(). The thread that calls this function first is considered "main thread" and other threads will have their thread id (pthread_self()) printed in the log message so it is easy to detect from where it is coming.

Log domains is the Eina way to differentiate messages. There might be different domains to represent different modules, different feature-set, different categories and so on. Filtering can be applied to domain names by means of `EINA_LOG_LEVELS` environment variable or eina_log_domain_level_set().

The different logging levels serve to customize the amount of debugging one want to take and may be used to automatically call abort() once some given level message is printed. This is controlled by environment variable `EINA_LOG_ABORT` and the level to be considered critical with `EINA_LOG_ABORT_LEVEL`. These can be changed with eina_log_abort_on_critical_set() and eina_log_abort_on_critical_level_set().

The default maximum level to print is defined by environment variable `EINA_LOG_LEVEL`, but may be set per-domain with `EINA_LOG_LEVELS`. It will default to EINA_LOG_ERR. This can be changed with eina_log_level_set().

To use the log system Eina must be initialized with eina_init() and later shut down with eina_shutdown(). Here is a straightforward example:

//Compile with:
//gcc -Wall -o eina_log_01 eina_log_01.c `pkg-config --cflags --libs eina`
#include <stdlib.h>
#include <stdio.h>
#include <Eina.h>
void test_warn(void)
{
EINA_LOG_WARN("Here is a warning message");
}
int main(void)
{
if (!eina_init())
{
printf("log during the initialization of Eina_Log module\n");
return EXIT_FAILURE;
}
eina_log_level_set(EINA_LOG_LEVEL_WARN);
test_warn();
eina_shutdown();
return EXIT_SUCCESS;
}
Eina.h
Eina Utility library.
eina_log_level_set
EINA_API void eina_log_level_set(int level)
Sets the default log level.
Definition eina_log.c:1733
EINA_LOG_WARN
#define EINA_LOG_WARN(fmt,...)
Logs a message with level WARN on the default domain with the specified format.
Definition eina_log.h:392
EINA_LOG_LEVEL_WARN
@ EINA_LOG_LEVEL_WARN
Warning log level.
Definition eina_log.h:459
eina_shutdown
EINA_API int eina_shutdown(void)
Shuts down the Eina library.
Definition eina_main.c:379
eina_init
EINA_API int eina_init(void)
Initializes the Eina library.
Definition eina_main.c:291

Compile this code with the following command:

    gcc -Wall -o eina_log_01 eina_log_01.c `pkg-config --cflags --libs eina`

Now execute the program with:

    EINA_LOG_LEVEL=2 ./eina_log_01

You should see a message displayed in the terminal.

For more information, you can look at the Log Tutorial.

## Macro Definition Documentation

## EINA_LOG_DOMAIN_DEFAULT

#define EINA_LOG_DOMAIN_DEFAULT EINA_LOG_DOMAIN_GLOBAL

This macro defines the domain to use with the macros EINA_LOG_DOM_DBG(), EINA_LOG_DOM_INFO(), EINA_LOG_DOM_WARN(), EINA_LOG_DOM_ERR() and EINA_LOG_DOM_CRIT().

If not defined prior to the inclusion of this header, then it defaults to EINA_LOG_DOMAIN_GLOBAL.

Note
  One may like to redefine this in its code to avoid typing too much. In this case the recommended way is:

#include <Eina.h>
#undef EINA_LOG_DOMAIN_DEFAULT
#define EINA_LOG_DOMAIN_DEFAULT _log_dom
static int _log_dom = -1;
int main(void)
{
eina_init();
_log_dom = eina_log_domain_register("mydom", EINA_COLOR_CYAN);
EINA_LOG_ERR("using my own domain");
return 0;
}
EINA_LOG_ERR
#define EINA_LOG_ERR(fmt,...)
Logs a message with level ERROR on the default domain with the specified format.
Definition eina_log.h:376
eina_log_domain_register
EINA_API int eina_log_domain_register(const char *name, const char *color)
Definition eina_log.c:1885

Warning
  If one defines the domain prior to inclusion of this header, the defined log domain symbol must be defined prior as well, otherwise the inlined functions defined by Eina will fail to find the symbol, causing build failure.

#define EINA_LOG_DOMAIN_DEFAULT _log_dom
static int _log_dom = -1; // must come before inclusion of Eina.h!
#include <Eina.h>
int main(void)
{
eina_init();
_log_dom = eina_log_domain_register("mydom", EINA_COLOR_CYAN);
EINA_LOG_ERR("using my own domain");
return 0;
}

## EINA_LOG

#define EINA_LOG | ( |  | DOM,
|  |  | LEVEL,
|  |  | fmt,
|  |  | ... )

Value:
do { (void) DOM; (void) LEVEL; (void) fmt; } while (0)

Logs a message on the specified domain, level and format.

Note
  If `EINA_LOG_LEVEL_MAXIMUM` is defined, then messages larger than this value will be ignored regardless of current domain level, the eina_log_print() is not even called! Most compilers will just detect the two integers make the branch impossible and remove the branch and function call all together. Take this as optimization tip and possible remove debug messages from binaries to be deployed, saving on hot paths. Never define `EINA_LOG_LEVEL_MAXIMUM` on public header files.

## EINA_LOG_DOM_CRIT

#define EINA_LOG_DOM_CRIT | ( |  | DOM,
|  |  | fmt,
|  |  | ... )

Value:
EINA_LOG(DOM, EINA_LOG_LEVEL_CRITICAL, fmt, ## __VA_ARGS__)
EINA_LOG
#define EINA_LOG(DOM, LEVEL, fmt,...)
Logs a message on the specified domain, level and format.
Definition eina_log.h:321
EINA_LOG_LEVEL_CRITICAL
@ EINA_LOG_LEVEL_CRITICAL
Critical log level.
Definition eina_log.h:457

Logs a message with level CRITICAL on the specified domain and format.

## EINA_LOG_DOM_ERR

#define EINA_LOG_DOM_ERR | ( |  | DOM,
|  |  | fmt,
|  |  | ... )

Value:
EINA_LOG(DOM, EINA_LOG_LEVEL_ERR, fmt, ## __VA_ARGS__)
EINA_LOG_LEVEL_ERR
@ EINA_LOG_LEVEL_ERR
Error log level.
Definition eina_log.h:458

Logs a message with level ERROR on the specified domain and format.

## EINA_LOG_DOM_INFO

#define EINA_LOG_DOM_INFO | ( |  | DOM,
|  |  | fmt,
|  |  | ... )

Value:
EINA_LOG(DOM, EINA_LOG_LEVEL_INFO, fmt, ## __VA_ARGS__)
EINA_LOG_LEVEL_INFO
@ EINA_LOG_LEVEL_INFO
Information log level.
Definition eina_log.h:460

Logs a message with level INFO on the specified domain and format.

Referenced by eina_log_timing().

## EINA_LOG_DOM_DBG

#define EINA_LOG_DOM_DBG | ( |  | DOM,
|  |  | fmt,
|  |  | ... )

Value:
EINA_LOG(DOM, EINA_LOG_LEVEL_DBG, fmt, ## __VA_ARGS__)
EINA_LOG_LEVEL_DBG
@ EINA_LOG_LEVEL_DBG
Debug log level.
Definition eina_log.h:461

Logs a message with level DEBUG on the specified domain and format.

## EINA_LOG_DOM_WARN

#define EINA_LOG_DOM_WARN | ( |  | DOM,
|  |  | fmt,
|  |  | ... )

Value:
EINA_LOG(DOM, EINA_LOG_LEVEL_WARN, fmt, ## __VA_ARGS__)

Logs a message with level WARN on the specified domain and format.

## EINA_LOG_CRIT

#define EINA_LOG_CRIT | ( |  | fmt,
|  |  | ... )

Value:
EINA_LOG(EINA_LOG_DOMAIN_DEFAULT, \
EINA_LOG_LEVEL_CRITICAL, \
fmt, \
## __VA_ARGS__)
EINA_LOG_DOMAIN_DEFAULT
#define EINA_LOG_DOMAIN_DEFAULT
This macro defines the domain to use with the macros EINA_LOG_DOM_DBG(), EINA_LOG_DOM_INFO(),...
Definition eina_log.h:284

Logs a message with level CRITICAL on the default domain with the specified format.

Referenced by emotion_init().

## EINA_LOG_ERR

#define EINA_LOG_ERR | ( |  | fmt,
|  |  | ... )

Value:
EINA_LOG(EINA_LOG_DOMAIN_DEFAULT, EINA_LOG_LEVEL_ERR, fmt, ## __VA_ARGS__)

Logs a message with level ERROR on the default domain with the specified format.

Examples
  client.c, eina_log_02.c, and eina_simple_xml_parser_01.c.

Referenced by ecore_audio_init(), ecore_buffer_init(), ecore_buffer_queue_init(), ecore_con_init(), ecore_drm2_init(), ecore_drm_init(), ecore_evas_init(), ecore_event_init(), ecore_file_init(), ecore_imf_evas_event_key_up_wrap(), ecore_imf_init(), ecore_init(), ecore_ipc_init(), ecore_sdl_init(), ecore_win32_dnd_init(), ecore_win32_init(), ecore_wl2_init(), ecore_wl2_shutdown(), ecore_wl_init(), ector_init(), ector_shutdown(), edje_init(), eet_init(), eeze_init(), eeze_shutdown(), efreet_shutdown(), eina_freeq_ptr_add(), eina_init(), eina_inlist_remove(), eina_mmap_safety_enabled_set(), eina_sched_prio_drop(), eio_init(), eldbus_init(), elput_init(), elua_init(), elua_shutdown(), embryo_init(), emile_init(), ethumb_client_init(), ethumb_init(), ethumb_shutdown(), evas_init(), and evas_shutdown().

## EINA_LOG_INFO

#define EINA_LOG_INFO | ( |  | fmt,
|  |  | ... )

Value:
EINA_LOG(EINA_LOG_DOMAIN_DEFAULT, EINA_LOG_LEVEL_INFO, fmt, ## __VA_ARGS__)

Logs a message with level INFO on the default domain with the specified format.

Examples
  eina_log_02.c, and eina_log_03.c.

Referenced by eina_sched_prio_drop().

## EINA_LOG_WARN

#define EINA_LOG_WARN | ( |  | fmt,
|  |  | ... )

Value:
EINA_LOG(EINA_LOG_DOMAIN_DEFAULT, EINA_LOG_LEVEL_WARN, fmt, ## __VA_ARGS__)

Logs a message with level WARN on the default domain with the specified format.

Examples
  eina_log_01.c.

## EINA_LOG_DBG

#define EINA_LOG_DBG | ( |  | fmt,
|  |  | ... )

Value:
EINA_LOG(EINA_LOG_DOMAIN_DEFAULT, EINA_LOG_LEVEL_DBG, fmt, ## __VA_ARGS__)

Logs a message with level DEBUG on the default domain with the specified format.

Examples
  eina_log_02.c.

## Enumeration Type Documentation

## _Eina_Log_Level

enum _Eina_Log_Level

List of available logging levels.

Enumerator
EINA_LOG_LEVEL_CRITICAL | Critical log level.
EINA_LOG_LEVEL_ERR | Error log level.
EINA_LOG_LEVEL_WARN | Warning log level.
EINA_LOG_LEVEL_INFO | Information log level.
EINA_LOG_LEVEL_DBG | Debug log level.
EINA_LOG_LEVELS | Count of default log levels.
EINA_LOG_LEVEL_UNKNOWN | Unknown level.

## _Eina_Log_State

enum _Eina_Log_State

List of available log states.

Enumerator
EINA_LOG_STATE_START | Logging is Started.
EINA_LOG_STATE_STOP | Logging is Stopped.

## Function Documentation

## eina_log_level_check()

Eina_Bool eina_log_level_check | ( | int | level | ) |

inline static

Checks whenever the given level should be printed out.

Parameters

  level | The level to print

This is useful to enable certain blocks of code just when given level is to be used.

#include <Eina.h>
void my_func(void *data)
{
if (eina_log_level_check(EINA_LOG_LEVEL_WARN))
expensive_debugging_code(data);
my_func_code(data);
}
eina_log_level_check
static Eina_Bool eina_log_level_check(int level)
Checks whenever the given level should be printed out.
Definition eina_inline_log.x:52

Returns
  EINA_TRUE if level is equal or smaller than the current global logging level.

References eina_log_level_get().

## eina_log_domain_level_check()

Eina_Bool eina_log_domain_level_check | ( | int | domain,
|  | int | level )

inline static

Checks whenever the given level should be printed out.

Parameters

  domain | The domain to check
  level | The level to print

This is useful to enable certain blocks of code just when given level is to be used.

#include <Eina.h>
extern int _my_log_dom;
void my_func(void *data)
{
if (eina_log_domain_level_check(_my_log_dom, EINA_LOG_LEVEL_WARN))
expensive_debugging_code(data);
my_func_code(data);
}
eina_log_domain_level_check
static Eina_Bool eina_log_domain_level_check(int domain, int level)
Checks whenever the given level should be printed out.
Definition eina_inline_log.x:84

Returns
  EINA_TRUE if level is equal or smaller than the current domain logging level.

References EINA_FALSE, EINA_LIKELY, eina_log_domain_registered_level_get(), and EINA_LOG_LEVEL_UNKNOWN.

Referenced by efreet_trash_ls().

## eina_log_level_name_get()

const char * eina_log_level_name_get | ( | int | level,
|  | char | name[4] )

inline static

Function to format the level as a 3 character (+1 null byte) string.

This function converts the given level to a known string name (CRI, ERR, WRN, INF or DBG) or a zero-padded 3-character string. In any case the last byte will contain a trailing null byte.

If extreme level values are used (greater than 999 and smaller than -99), then the value will just consider the less significant part. This is so uncommon that users should handle this in their code.

Parameters

  level | what level value to use.
  name | where to write the actual value.

Returns
  pointer to `name`.

References EINA_LOG_LEVELS, and EINA_UNLIKELY.

## eina_log_level_color_get()

const char * eina_log_level_color_get | ( | int | level | ) |

inline static

Function to get recommended color value for level.

This function will not check if colors are enabled or not before returning the level color. If you desire such check, use eina_log_level_color_if_enabled_get().

Parameters

  level | what level value to use.

Returns
  pointer to null byte terminated ANSI color string to be used in virtual terminals supporting VT100 color codes.

See also
  eina_log_level_color_if_enabled_get()

Referenced by eina_log_level_color_if_enabled_get().

## eina_log_level_color_if_enabled_get()

const char * eina_log_level_color_if_enabled_get | ( | int | level | ) |

inline static

Function to get recommended color value for level, if colors are enabled.

This function will check if colors are enabled or not before returning the level color. If colors are disabled, then empty string is returned.

Parameters

  level | what level value to use.

Returns
  pointer to null byte terminated ANSI color string to be used in virtual terminals supporting VT100 color codes. If colors are disabled, the empty string is returned.

References eina_log_color_disable_get(), and eina_log_level_color_get().

## eina_log_threads_enable()

EINA_API void eina_log_threads_enable | ( | void |  | ) |

Enable logging module to handle threads.

There is no disable option on purpose, if it is enabled, there is no way back until you call the last eina_shutdown().

There is no function to retrieve if threads are enabled as one is not supposed to know this from outside.

After this call is executed at least once, if Eina was compiled with threads support then logging will lock around debug messages and threads that are not the main thread will have its identifier printed.

The main thread is considered the thread where the first eina_init() was called.

References EINA_TRUE.

## eina_log_print_cb_set()

EINA_API void eina_log_print_cb_set | ( | Eina_Log_Print_Cb | cb,
|  | void * | data )

Sets logging method to use.

Parameters

  [in] | cb | The callback to call when printing a log.
  [in] | data | The data to pass to the callback.

By default, eina_log_print_cb_stderr() is used.

Note
  MT: Safe to call from any thread.
  MT: Given function cb will be called protected by mutex. This means you're safe from other calls but you should never call eina_log_print(), directly or indirectly.

References eina_log_print_cb_stderr().

## eina_log_level_set()

EINA_API void eina_log_level_set | ( | int | level | ) |

Sets the default log level.

Parameters

  [in] | level | The log level.

This function sets the log level `level`. It is used in eina_log_print().

Note
  this is initially set to envvar EINA_LOG_LEVEL by eina_init().

See also
  eina_log_level_get()

References EINA_LIKELY, EINA_LOG_DOMAIN_GLOBAL, and _Eina_Log_Domain::level.

## eina_log_level_get()

EINA_API int eina_log_level_get | ( | void |  | ) |

Gets the default log level.

Returns
  The log level that limits eina_log_print().

See also
  eina_log_level_set()

Referenced by eina_log_level_check().

## eina_log_main_thread_check()

EINA_API Eina_Bool eina_log_main_thread_check | ( | void |  | ) |

Checks if current thread is the main thread.

If there is no thread support (compiled with –disable-pthreads) or threads were not enabled, then EINA_TRUE is returned. The only case where EINA_FALSE is returned is when threads were successfully enabled but the current thread is not the one that called eina_log_threads_init() (the main thread).

Returns
  EINA_TRUE if the current thread is the one that called eina_log_threads_init(), otherwise EINA_FALSE.

References EINA_TRUE.

## eina_log_color_disable_set()

EINA_API void eina_log_color_disable_set | ( | Eina_Bool | disabled | ) |

Enables or disables colored text in the logs.

Parameters

  [in] | disabled | If EINA_TRUE, color logging should be disabled.

Note
  this is initially set to envvar EINA_LOG_COLOR_DISABLE by eina_init().

See also
  eina_log_color_disable_get()

References _Eina_Log_Domain::color, _Eina_Log_Domain::domain_str, and _Eina_Log_Domain::name.

## eina_log_color_disable_get()

EINA_API Eina_Bool eina_log_color_disable_get | ( | void |  | ) |

Determines if color logging is enabled or disabled.

Returns
  If EINA_TRUE, color logging is disabled.

See also
  eina_log_color_disable_set()

References EINA_TRUE.

Referenced by eina_log_level_color_if_enabled_get().

## eina_log_file_disable_set()

EINA_API void eina_log_file_disable_set | ( | Eina_Bool | disabled | ) |

Sets if originating file name logging should be disabled.

Parameters

  [in] | disabled | If EINA_TRUE, file name logging should be disabled.

Note
  this is initially set to envvar EINA_LOG_FILE_DISABLE by eina_init().

See also
  eina_log_file_disable_get()

## eina_log_file_disable_get()

EINA_API Eina_Bool eina_log_file_disable_get | ( | void |  | ) |

Gets if originating file name logging should be disabled.

Returns
  If EINA_TRUE, file name logging should be disabled.

See also
  eina_log_file_disable_set()

References EINA_TRUE.

## eina_log_function_disable_set()

EINA_API void eina_log_function_disable_set | ( | Eina_Bool | disabled | ) |

Sets if originating function name logging should be disabled.

Parameters

  [in] | disabled | If EINA_TRUE, function name logging should be disabled.

Note
  this is initially set to envvar EINA_LOG_FUNCTION_DISABLE by eina_init().

See also
  eina_log_function_disable_get()

## eina_log_function_disable_get()

EINA_API Eina_Bool eina_log_function_disable_get | ( | void |  | ) |

Gets if originating function name logging should be disabled.

Returns
  If EINA_TRUE, function name logging should be disabled.

See also
  eina_log_function_disable_set()

References EINA_TRUE.

## eina_log_abort_on_critical_set()

EINA_API void eina_log_abort_on_critical_set | ( | Eina_Bool | abort_on_critical | ) |

Sets if critical messages should abort the program.

Parameters

  [in] | abort_on_critical | If EINA_TRUE, messages with level equal or smaller than eina_log_abort_on_critical_level_get() will abort the program.

Note
  this is initially set to envvar EINA_LOG_ABORT by eina_init().

See also
  eina_log_abort_on_critical_get()
  eina_log_abort_on_critical_level_set()

Referenced by ecore_buffer_queue_init().

## eina_log_abort_on_critical_get()

EINA_API Eina_Bool eina_log_abort_on_critical_get | ( | void |  | ) |

Gets if critical messages should abort the program.

Returns
  If EINA_TRUE, any messages with level equal or smaller than eina_log_abort_on_critical_level_get() will abort the program.

See also
  eina_log_abort_on_critical_set()
  eina_log_abort_on_critical_level_set()

References EINA_FALSE.

## eina_log_abort_on_critical_level_set()

EINA_API void eina_log_abort_on_critical_level_set | ( | int | critical_level | ) |

Sets level that triggers abort if abort-on-critical is set.

Parameters

  [in] | critical_level | Levels equal or smaller than the given value will trigger program abortion if eina_log_abort_on_critical_get() returns EINA_TRUE.

Note
  this is initially set to envvar EINA_LOG_ABORT_LEVEL by eina_init().

See also
  eina_log_abort_on_critical_level_get()
  eina_log_abort_on_critical_get()

Referenced by ecore_buffer_queue_init().

## eina_log_abort_on_critical_level_get()

EINA_API int eina_log_abort_on_critical_level_get | ( | void |  | ) |

Gets level that triggers abort if abort-on-critical is set.

Returns
  Critical level equal or smaller than value will trigger program abortion if eina_log_abort_on_critical_get() returns EINA_TRUE.

See also
  eina_log_abort_on_critical_level_set()
  eina_log_abort_on_critical_get()

## eina_log_domain_level_set()

EINA_API void eina_log_domain_level_set | ( | const char * | domain_name,
|  | int | level )

Sets the domain level given its name.

This call has the same effect as setting EINA_LOG_LEVELS=<`domain_name>`:<`level>`

Parameters

  [in] | domain_name | Domain name to change the level. It may be of a still not registered domain. If the domain is not registered yet, it will be saved as a pending set and applied upon registration.
  [in] | level | Level to use to limit eina_log_print() for given domain.

References eina_inlist_append(), EINA_INLIST_FOREACH, EINA_INLIST_GET, EINA_SAFETY_ON_NULL_RETURN, and _Eina_Log_Domain::level.

## eina_log_domain_level_get()

EINA_API int eina_log_domain_level_get | ( | const char * | domain_name | ) |

Gets the domain level given its name.

Parameters

  [in] | domain_name | Domain name to retrieve the level. It may be of a still not registered domain. If the domain is not registered yet, but there is a pending value, either from eina_log_domain_level_set(),EINA_LOG_LEVELS environment variable or from EINA_LOG_LEVELS_GLOB, these are returned. If nothing else was found, then the global/default level (eina_log_level_get()) is returned.

Returns
  Level to use to limit eina_log_print() for given domain. On error (`domain_name` == NULL), EINA_LOG_LEVEL_UNKNOWN is returned.

See also
  eina_log_domain_level_set()
  eina_log_domain_registered_level_get()

References EINA_INLIST_FOREACH, EINA_LOG_LEVEL_UNKNOWN, EINA_SAFETY_ON_NULL_RETURN_VAL, and _Eina_Log_Domain::level.

## eina_log_domain_registered_level_get()

EINA_API int eina_log_domain_registered_level_get | ( | int | domain | ) |

Gets the domain level given its identifier.

Parameters

  [in] | domain | Identifier, so it must be previously registered with eina_log_domain_register(). It's a much faster version of eina_log_domain_level_get(), but relies on domain being present.

Returns
  EINA_TRUE if level should be printed, EINA_FALSE if not. (domain's level is greater or equal level).

References EINA_LOG_LEVEL_UNKNOWN, EINA_SAFETY_ON_FALSE_RETURN_VAL, EINA_SAFETY_ON_TRUE_RETURN_VAL, and _Eina_Log_Domain::level.

Referenced by eina_log_domain_level_check().

## eina_log_domain_registered_level_set()

EINA_API void eina_log_domain_registered_level_set | ( | int | domain,
|  | int | level )

Sets the domain level given its identifier.

Parameters

  [in] | domain | Identifier, so it must be previously registered with eina_log_domain_register(). It's a much faster version of eina_log_domain_level_get(), but relies on domain being present.
  [in] | level | Level to use to limit eina_log_print() for given domain.

Since
  1.10

References EINA_SAFETY_ON_FALSE_RETURN, EINA_SAFETY_ON_TRUE_RETURN, and _Eina_Log_Domain::level.

## eina_log_domain_register()

EINA_API int eina_log_domain_register | ( | const char * | name,
|  | const char * | color )

Parameters

  [in] | name | Domain name
  [in] | color | Color of the domain name

Returns
  Domain index that will be used as the DOMAIN parameter on log macros. A negative return value means an error occurred.

Note
  MT: Safe to call from any thread.

References EINA_SAFETY_ON_NULL_RETURN_VAL.

Referenced by ecore_audio_init(), ecore_buffer_init(), ecore_buffer_queue_init(), ecore_con_init(), ecore_drm2_init(), ecore_drm_init(), ecore_evas_init(), ecore_event_init(), ecore_file_init(), ecore_imf_init(), ecore_init(), ecore_ipc_init(), ecore_sdl_init(), ecore_win32_init(), ecore_wl2_init(), ecore_wl_init(), ector_init(), edje_init(), eet_init(), eeze_init(), eina_init(), eina_mmap_safety_enabled_set(), eio_init(), eldbus_init(), elm_quicklaunch_init(), elput_init(), elua_init(), embryo_init(), emile_init(), emotion_init(), ethumb_client_init(), ethumb_init(), and evas_init().

## eina_log_domain_unregister()

EINA_API void eina_log_domain_unregister | ( | int | domain | ) |

Forgets about a logging domain registered by eina_log_domain_register().

Parameters

  [in] | domain | Domain identifier as reported by eina_log_domain_register(), must be >= 0.

Note
  MT: Safe to call from any thread.

References EINA_SAFETY_ON_FALSE_RETURN.

Referenced by ecore_audio_shutdown(), ecore_buffer_init(), ecore_buffer_queue_init(), ecore_buffer_queue_shutdown(), ecore_buffer_shutdown(), ecore_con_shutdown(), ecore_drm2_init(), ecore_drm2_shutdown(), ecore_drm_init(), ecore_drm_shutdown(), ecore_evas_shutdown(), ecore_event_shutdown(), ecore_file_shutdown(), ecore_imf_shutdown(), ecore_ipc_init(), ecore_ipc_shutdown(), ecore_sdl_shutdown(), ecore_shutdown(), ecore_win32_init(), ecore_win32_shutdown(), ecore_wl2_init(), ecore_wl2_shutdown(), ecore_wl_init(), ecore_x_init(), ecore_x_init_from_display(), ector_shutdown(), edje_init(), eet_init(), eet_shutdown(), eeze_init(), eeze_shutdown(), eio_init(), eio_shutdown(), eldbus_init(), eldbus_shutdown(), elm_quicklaunch_init(), elm_quicklaunch_shutdown(), elput_shutdown(), elua_shutdown(), embryo_shutdown(), emile_shutdown(), emotion_init(), emotion_shutdown(), ethumb_client_shutdown(), ethumb_init(), ethumb_shutdown(), evas_init(), and evas_shutdown().

## eina_log_print()

EINA_API void eina_log_print | ( | int | domain,
|  | Eina_Log_Level | level,
|  | const char * | file,
|  | const char * | function,
|  | int | line,
|  | const char * | fmt,
|  |  | ... )

Prints out log message using given domain and level.

Note
  Usually you'll not use this function directly but the helper macros EINA_LOG(), EINA_LOG_DOM_CRIT(), EINA_LOG_CRIT() and so on. See eina_log.h

Parameters

  [in] | domain | Logging domain to use or `EINA_LOG_DOMAIN_GLOBAL` if you registered none. It is recommended that modules and applications have their own logging domain.
  [in] | level | Message level, those with level greater than user specified value (eina_log_level_set() or environment variables EINA_LOG_LEVEL, EINA_LOG_LEVELS) will be ignored.
  [in] | file | Filename that originated the call, must not be `NULL`.
  [in] | function | Function that originated the call, must not be `NULL`.
  [in] | line | Originating line in file.
  [in] | fmt | Printf-like format to use. Should not provide trailing ' ' as it is automatically included.
  [in] | ... | Variadic args.

Note
  MT: This function may be called from different threads if eina_log_threads_enable() was called before.

References _eina_log_state_init, _eina_log_state_shutdown, EINA_API, EINA_ARG_NONNULL, eina_log_console_color_set(), eina_log_print_cb_file(), eina_log_print_cb_journald(), eina_log_print_cb_stderr(), eina_log_print_cb_stdout(), eina_log_vprint(), EINA_NOINSTRUMENT, and EINA_PRINTF.

## eina_log_vprint()

EINA_API void eina_log_vprint | ( | int | domain,
|  | Eina_Log_Level | level,
|  | const char * | file,
|  | const char * | fnc,
|  | int | line,
|  | const char * | fmt,
|  | va_list | args )

Prints out log message using given domain and level.

Note
  Usually you'll not use this function directly but the helper macros EINA_LOG(), EINA_LOG_DOM_CRIT(), EINA_LOG_CRIT() and so on. See eina_log.h

Parameters

  [in] | domain | Logging domain to use or `EINA_LOG_DOMAIN_GLOBAL` if you registered none. It is recommended that modules and applications have their own logging domain.
  [in] | level | Message level, those with level greater than user specified value (eina_log_level_set() or environment variables EINA_LOG_LEVEL, EINA_LOG_LEVELS) will be ignored.
  [in] | file | Filename that originated the call, must not be `NULL`.
  [in] | fnc | Function that originated the call, must not be `NULL`.
  [in] | line | Originating line in file.
  [in] | fmt | Printf-like format to use. Should not provide trailing ' ' as it is automatically included.
  [in] | args | The arguments needed by the format.

Note
  MT: this function may be called from different threads if eina_log_threads_enable() was called before.

See also
  eina_log_print()

References EINA_UNLIKELY.

Referenced by eina_log_print().

## eina_log_print_cb_stdout()

EINA_API void eina_log_print_cb_stdout | ( | const Eina_Log_Domain * | d,
|  | Eina_Log_Level | level,
|  | const char * | file,
|  | const char * | fnc,
|  | int | line,
|  | const char * | fmt,
|  | void * | data,
|  | va_list | args )

Alternative logging method, this will output to standard output stream.

Parameters

  [in] | d | The domain.
  [in] | level | The level.
  [in] | file | The file which is logged.
  [in] | fnc | The function which is logged.
  [in] | line | The line which is logged.
  [in] | fmt | The output format to use.
  [in] | data | Not used.
  [in] | args | The arguments needed by the format.

This method will colorize output based on domain provided color and message logging level. To disable color, set environment variable EINA_LOG_COLOR_DISABLE=1. Similarly, to disable file and line information, set EINA_LOG_FILE_DISABLE=1 or EINA_LOG_FUNCTION_DISABLE=1 to avoid function name in output. It is not acceptable to have both EINA_LOG_FILE_DISABLE and EINA_LOG_FUNCTION_DISABLE at the same time, in this case just EINA_LOG_FUNCTION_DISABLE will be considered and file information will be printed anyways.

Note
  MT: If threads are enabled, this function is called within locks.
  MT: Threads different from main thread will have thread id appended to domain name.

References EINA_UNUSED.

Referenced by eina_log_print().

## eina_log_print_cb_stderr()

EINA_API void eina_log_print_cb_stderr | ( | const Eina_Log_Domain * | d,
|  | Eina_Log_Level | level,
|  | const char * | file,
|  | const char * | fnc,
|  | int | line,
|  | const char * | fmt,
|  | void * | data,
|  | va_list | args )

Default logging method, this will output to standard error stream.

Parameters

  [in] | d | The domain.
  [in] | level | The level.
  [in] | file | The file which is logged.
  [in] | fnc | The function which is logged.
  [in] | line | The line which is logged.
  [in] | fmt | The output format to use.
  [in] | data | Not used.
  [in] | args | The arguments needed by the format.

This method will colorize output based on domain provided color and message logging level.

To disable color, set environment variable EINA_LOG_COLOR_DISABLE=1. To enable color, even if directing to a file or when using a non-supported color terminal, use EINA_LOG_COLOR_DISABLE=0. If EINA_LOG_COLOR_DISABLE is unset (or -1), then Eina will disable color if terminal ($TERM) is unsupported or if redirecting to a file. Similarly, to disable file and line information, set EINA_LOG_FILE_DISABLE=1 or EINA_LOG_FUNCTION_DISABLE=1 to avoid function name in output. It is not acceptable to have both EINA_LOG_FILE_DISABLE and EINA_LOG_FUNCTION_DISABLE at the same time, in this case just EINA_LOG_FUNCTION_DISABLE will be considered and file information will be printed anyways.

Note
  MT: If threads are enabled, this function is called within locks.
  MT: Threads different from main thread will have thread id appended to domain name.

References EINA_UNUSED.

Referenced by eina_log_print(), eina_log_print_cb_journald(), and eina_log_print_cb_set().

## eina_log_print_cb_file()

EINA_API void eina_log_print_cb_file | ( | const Eina_Log_Domain * | d,
|  | Eina_Log_Level | level,
|  | const char * | file,
|  | const char * | fnc,
|  | int | line,
|  | const char * | fmt,
|  | void * | data,
|  | va_list | args )

Alternative logging method, this will output to given file stream.

Parameters

  [in] | d | The domain.
  [in] | level | Not used.
  [in] | file | The file which is logged.
  [in] | fnc | The function which is logged.
  [in] | line | The line which is logged.
  [in] | fmt | The output format to use.
  [in] | data | The file which will store the output (as a FILE *).
  [in] | args | The arguments needed by the format.

This method will never output color.

Note
  MT: If threads are enabled, this function is called within locks.
  MT: Threads different from main thread will have thread id appended to domain name.

References EINA_SAFETY_ON_NULL_RETURN, and EINA_UNUSED.

Referenced by eina_log_print().

## eina_log_print_cb_journald()

EINA_API void eina_log_print_cb_journald | ( | const Eina_Log_Domain * | d,
|  | Eina_Log_Level | level,
|  | const char * | file,
|  | const char * | fnc,
|  | int | line,
|  | const char * | fmt,
|  | void * | data,
|  | va_list | args )

Alternative logging method, this will output to systemd journal.

Parameters

  [in] | d | The domain.
  [in] | level | Not used.
  [in] | file | The file which is logged.
  [in] | fnc | The function which is logged.
  [in] | line | The line which is logged.
  [in] | fmt | The output format to use.
  [in] | data | The file which will store the output (as a FILE *).
  [in] | args | The arguments needed by the format.

This method will never output color.

Note
  If systemd journal is not there it will display error on stderr.
  If the process has been started by systemd this will be the default logging method.

Since
  1.8

References EINA_LIKELY, eina_log_print_cb_stderr(), eina_strbuf_free(), eina_strbuf_new(), eina_strbuf_string_get(), and EINA_UNUSED.

Referenced by eina_log_print().

## eina_log_console_color_set()

EINA_API void eina_log_console_color_set | ( | FILE * | fp,
|  | const char * | color )

Configures console color of given file.

Parameters

  [in] | fp | File to configure console color (usually stderr or stdout).
  [in] | color | A VT color code such as EINA_COLOR_RED or EINA_COLOR_RESET.

Note
  If color is disabled, nothing is done. See eina_log_color_disable_get()
  On windows, both fp and color is converted automatically.

Since
  1.7

References EINA_SAFETY_ON_NULL_RETURN.

Referenced by eina_log_print().

## eina_log_timing()

EINA_API void eina_log_timing | ( | int | domain,
|  | Eina_Log_State | state,
|  | const char * | phase )

Starts or stops the timing of a phase.

Parameters

  [in] | domain | The domain.
  [in] | state | State indicating if we are starting or stopping a phase.
  [in] | phase | The name of the phase to be used in the log.

Note
  One domain can be in only one phase at a time.
  If you change the name of the phase, it is assumed that the previous phase has stopped.
  The phase name should be available for all the life of the timing.

Since
  1.8

References EINA_LOG_DOM_INFO, EINA_LOG_STATE_INIT, EINA_LOG_STATE_SHUTDOWN, EINA_LOG_STATE_START, EINA_LOG_STATE_STOP, eina_log_timing(), and EINA_UNLIKELY.

Referenced by ecore_audio_init(), ecore_audio_shutdown(), ecore_con_init(), ecore_con_shutdown(), ecore_evas_init(), ecore_evas_shutdown(), ecore_init(), ecore_shutdown(), ector_init(), ector_shutdown(), edje_init(), eet_init(), eet_shutdown(), eina_init(), eina_log_timing(), eina_shutdown(), eio_init(), eio_shutdown(), elm_quicklaunch_init(), elm_quicklaunch_shutdown(), elua_init(), elua_shutdown(), embryo_init(), embryo_shutdown(), emile_init(), emile_shutdown(), evas_init(), and evas_shutdown().