fixing some errors in logging functions

- removing warnings created by LOG_DBG() macro
- fixing syslog message error
- adding platform specific end of line
ulab-original
ilsimo 19 years ago
parent ba1ea148f4
commit ec3016ca87

@ -119,15 +119,15 @@ log_message(const unsigned int lvl, const char* msg, ...)
{ {
return LOG_ERROR_FILE_NOT_OPEN; return LOG_ERROR_FILE_NOT_OPEN;
} }
log_lvl2str(lvl, buff);
now_t = time(&now_t); now_t = time(&now_t);
now = localtime(&now_t); now = localtime(&now_t);
snprintf(buff+8, 21, "[%.4d%.2d%.2d-%.2d:%.2d:%.2d] ", (now->tm_year)+1900, (now->tm_mon)+1, snprintf(buff, 21, "[%.4d%.2d%.2d-%.2d:%.2d:%.2d] ", (now->tm_year)+1900, (now->tm_mon)+1,
now->tm_mday, now->tm_hour, now->tm_min, now->tm_sec); now->tm_mday, now->tm_hour, now->tm_min, now->tm_sec);
log_lvl2str(lvl, buff+20);
va_start(ap, msg); va_start(ap, msg);
len = vsnprintf(buff+28, LOG_BUFFER_SIZE, msg, ap); len = vsnprintf(buff+28, LOG_BUFFER_SIZE, msg, ap);
va_end(ap); va_end(ap);
@ -139,14 +139,24 @@ log_message(const unsigned int lvl, const char* msg, ...)
} }
/* forcing the end of message string */ /* forcing the end of message string */
buff[len+28] = '\r'; #ifdef _WIN32
buff[len+29] = '\n'; buff[len+28] = '\r';
buff[len+30] = '\0'; buff[len+29] = '\n';
buff[len+30] = '\0';
#else
#ifdef _MACOS
buff[len+28] = '\r';
buff[len+29] = '\0';
#else
buff[len+28] = '\n';
buff[len+29] = '\0';
#endif
#endif
if ( l_cfg->enable_syslog && (lvl <= l_cfg->log_level) ) if ( l_cfg->enable_syslog && (lvl <= l_cfg->log_level) )
{ {
/* log to syslog */ /* log to syslog */
syslog(log_xrdp2syslog(lvl), msg); syslog(log_xrdp2syslog(lvl), buff+20);
} }
if (lvl <= l_cfg->log_level) if (lvl <= l_cfg->log_level)

@ -49,7 +49,7 @@
#ifdef DEBUG #ifdef DEBUG
#define LOG_DBG(s,args...) log_message(LOG_LEVEL_DEBUG,s,args); #define LOG_DBG(s,args...) log_message(LOG_LEVEL_DEBUG,s,args);
#else #else
#define LOG_DBG #define LOG_DBG(s,args...)
#endif #endif
struct log_config struct log_config

Loading…
Cancel
Save