Skip to content
aquesnel edited this page Jan 7, 2021 · 8 revisions

still work in progress

The work has been started in PR #1633 and the new logging system is documented on the Logging page.

Goal

Eliminate all logs written to stdout/stdout. All logs should be written to log files. Don't have user to run xrdp/xrdp-sesman in foreground to investigate issues.

Current logging functions/macros (terribly confusing)

name defined at type normal build DEBUG
g_writeln() comon/os_calls.h function
log_message() common/log.h function
LLOGLN() many files macro do { if (_level < LOG_LEVEL) { g_write _args ; } } while (0)
LLOG() many files macro do { if (_level < LOG_LEVEL) { g_writeln _args ; } } while (0)
DEBUG() common/defines.h macro N/A g_writeln args;
LOG_DBG() common/log.h macro N/A log_message(LOG_LEVEL_DEBUG, )
LIB_DEBUG() common/defines.h macro N/A _mod->server_msg(_mod, _text, 1);
DLOG() libxrdp/xrdp_mppc_enc.c macro do {} while (0) g_printf _args

and more.

chansrv

name defined at type normal build DEBUG
LOG() chansrv.h macro g_write ; g_writeln _params;
LOGM() chansrv.h macro do { log_message _args ; } while (0)
log_error() many files macro g_write ; g_writeln _params;
log_always() many files macro g_write ; g_writeln _params;
log_info() many files macro g_write ; g_writeln _params;
log_debug() many files macro g_write ; g_writeln _params;

New logging functions

Almost all logs should be logged via log_message() as far as possible.

Log level TRACE is newly introduced log level which means more verbose then DEBUG.

Aliases (macro)

  • log_always(args..) -> log_message(LOG_LEVEL_ALWAYS, args)
  • log_error(args..) -> log_message(LOG_LEVEL_ERROR, args)
  • log_warning(args..) -> log_message(LOG_LEVEL_WARNING, args)
  • log_info(args..) -> log_message(LOG_LEVEL_INFO, args)
  • log_debug(args..) -> log_message(LOG_LEVEL_DEBUG, args)
  • log_trace(args..) -> log_message(LOG_LEVEL_TRACE, args)
  • log_trace_verbose(args..) -> log_message(LOG_LEVEL_TRACE, args) (debug build only)
#define log_always(args..)  log_message(LOG_LEVEL_ALWAYS, args);
#define log_error(args..)   log_message(LOG_LEVEL_ERROR, args);
#define log_warning(args..) log_message(LOG_LEVEL_WARNING, args);
#define log_info(args..)    log_message(LOG_LEVEL_INFO, args);
#define log_debug(args..)   log_message(LOG_LEVEL_DEBUG, args);
#define log_trace(args..)   log_message(LOG_LEVEL_TRACE, args);
#if defined(XRDP_DEBUG)
#define log_trace_verbose(args..) log_message(LOG_LEVEL_TRACE, args);
#else
#define log_trace_verbose(args..)
#endif

Usage of g_write(), g_writeln()

Limited to using really need to write stdout. Ex. output of xrdp -h.

Converting

before after
g_writeln() log_trace()
DEBUG() log_trace_verbose()
LLOGLN(0, ) log_trace()
LLOGLN(10, ) log_trace_verbose()
LOG_DBG() log_trace_verbose()
DLOG() log_trace_verbose()
log_message() log_*() matching log level
LIB_DEBUG() ?

chansrv

Clone this wiki locally