User Tools

Site Tools


Sidebar

Table Of Contents

endurox:v8.0.x:api:xatmi:tplogconfig.3

tplogconfig

Name

tplogconfig — Configure logger facilities

Synopsis

#include <ndebug.h>

#include <nerror.h>

int tplogconfig(int logger, int lev, char *debug_string, char *module, char *new_file);

Link with -lnstd -lpthread -lrt -lm

DESCRIPTION

Function does configure logging facilities - NDRX (XATMI internal logs), UBF (UBF internal logs( and TP (User logs). If not already logger started, then this function will initiate Enduro/X framework to load the logging settings from [@debug] ini section or from ndrxdebug.conf(5). Then with help of this function user is able to override loaded settings.

Also it is possible to set per thread logging, if facility code used here is LOG_FACILITY_TP_THREAD. Or it is possible to configure request based logging from this function, but tplogsetreqfile_direct(3) and tplogsetreqfile(3) is recommended to use instead.

The logging facility is set in logger parameter, you may unify settings for multiple facilities with bitwise OR. Th facilities defined are following:

/** settings for ATMI logging        */
#define LOG_FACILITY_NDRX           0x00000001
/** settings for UBF logging         */
#define LOG_FACILITY_UBF            0x00000002
/** settings for TP logging          */
#define LOG_FACILITY_TP             0x00000004
/** settings for TP, thread based logging */
#define LOG_FACILITY_TP_THREAD      0x00000008
/** tp, Request logging, thread based*/
#define LOG_FACILITY_TP_REQUEST     0x00000010
/** ndrx thread logging              */
#define LOG_FACILITY_NDRX_THREAD    0x00000020
/** ubf thread logging               */
#define LOG_FACILITY_UBF_THREAD     0x00000040
/** ndrx request logging             */
#define LOG_FACILITY_NDRX_REQUEST   0x00000080
/** ubf request logging              */
#define LOG_FACILITY_UBF_REQUEST    0x00000100

logger is mandatory parameter to the function. To configure logging level for given facilities, you may use lev to indicate one of the following levels:

#define log_always      1
#define log_error       2
#define log_warn        3
#define log_info        4
#define log_debug       5
#define log_dump        6 /* this is un-offical level, normally use 1..5 */

lev is optional parameter, and if not used, then set it to -1. Function accepts optional parameter debug_string, which is Enduro/X standard debug string. If field not set then it might be NULL or empty (EOS). If set, then it contains the configuration settings described in ndrxdebug.conf(5) or see ex_devguide(guides). One special note here is that, with debug string you may set log levels for NDRX, UBF and TP facilities, thus ndrx and ubf and "tp" log levels will affect the given logger settings (process/thread/request). For example tp will change the level of the given logger facility, per process (LOG_FACILITY_TP), per thread (LOG_FACILITY_TP_THREAD) or per request (LOG_FACILITY_TP_REQUEST).

If the lev parameter is present and it will override the given loggers settings from debug_string. The same applies if debug_string contains the logging file, the new_file is present (not NULL and not EOS) will override the output file setting if file param is present in debug_string.

module module indicates the module code string which is plotted in each logged line. This is valid only for TP loggers for NDRX and UBF it is ignored.

As the all logging functions checks the early log level set in process level (due to fact that at that point TLS might not be initialized), thus by changing thread or request log levels, may only reduce the log level. So system might be configured so that, in config process level logs are higher, and then threads or requests might request to make the level lower.

If process for fails to open log file, logger is switched to stderr.

THREAD SAFETY

tplogconfig() function is thread safe. Changing the log file name while other threads are logging is supported too.

Due to support of multi-threaded operations is implemented, there is limitation that process level loggers (LOG_FACILITY_NDRX, LOG_FACILITY_UBF and LOG_FACILITY_TP) cannot have each different output file name. If for one logger file name is changed it is automatically replaced for other logger facilities (topics) too.

RETURN VALUE

On success, tplogconfig() returns 0. On error, -1 is returned, with Nerror set to indicate the error.

ERRORS

Note that Nstrerror() returns generic error message plus custom message with debug info from last function call.

NEFORMAT Invalid format for debug_string.

NESYSTEM System error occurred. See the logs for more info.

EXAMPLE

See atmitest/test031_logging/atmiclt31.c for sample code.

BUGS

Report bugs to support@mavimax.com

COPYING

© Mavimax, Ltd