elog/doc/tutorial_01_add_log.md

1.7 KiB

Elog Tutorial: Add some Log (using)

@tableofcontents

You might not use the log directly. The reson is simple:

  • It is designed to be replaced by an other log library.

This permit you to use custom log library just replacing Macro and basic functions

Declaring the list of macro

debug.hpp

@include sample/debug.hpp

debug.cpp

@include sample/debug.cpp

  • on your main application:

@snippet sample/main.cpp elog_sample_main_include @snippet sample/main.cpp elog_sample_main_base

Using it

You just need to call the macro whe you want to add debug log:

@snippet sample/main.cpp elog_sample_main_log

Specification of logs

  • _CRITICAL(**); This will log the data and asert just after (display backtrace if possible)
  • _PRINT(**); display on console (can not be removed with the log-level)

Log in an external logger

You must specify an external function that is receiving the logs:

@snippet sample/main.cpp elog_sample_main_callback_DECLARATION

Now you must connect it on the elog backend:

@snippet sample/main.cpp elog_sample_main_callback_link

	elog::setCallbackLog(&myExternalLogCallback);

The full code of the callback: @snippet sample/main.cpp elog_sample_main_callback

you can test the program:

lutin -C -P -mdebug elog-sample?build?run:--elog-level=2