Commit c0486d50 authored by jehan's avatar jehan

migrate traces to bctbx

parent c8b49644
......@@ -70,15 +70,6 @@ do_stop()
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
RETVAL="$?"
[ "$RETVAL" = 2 ] && return 2
# Wait for children to finish too if this is a daemon that forks
# and if the daemon is only ever run from this initscript.
# If the above conditions are not satisfied then add some other code
# that waits for the process to drop all resources that could be
# needed by services started subsequently. A last resort is to
# sleep for some time.
start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
[ "$?" = 2 ] && return 2
# Many daemons don't delete their pidfiles when they exit.
rm -f $PIDFILE
return "$RETVAL"
}
......
......@@ -18,7 +18,7 @@
#include "logmanager.hh"
#include <string>
#include <ortp/ortp.h>
#include "bctoolbox/logging.h"
#include <syslog.h>
using namespace std;
......@@ -30,22 +30,22 @@ bool sUseSyslog = false;
namespace flexisip {
namespace log {
static void syslogHandler(const char *domain, OrtpLogLevel log_level, const char *str, va_list l) {
static void syslogHandler(const char *domain, BctbxLogLevel log_level, const char *str, va_list l) {
int syslev = LOG_ALERT;
switch (log_level) {
case ORTP_DEBUG:
case BCTBX_LOG_DEBUG:
syslev = LOG_DEBUG;
break;
case ORTP_MESSAGE:
case BCTBX_LOG_MESSAGE:
syslev = LOG_INFO;
break;
case ORTP_WARNING:
case BCTBX_LOG_WARNING:
syslev = LOG_WARNING;
break;
case ORTP_ERROR:
case BCTBX_LOG_ERROR:
syslev = LOG_ERR;
break;
case ORTP_FATAL:
case BCTBX_LOG_FATAL:
syslev = LOG_ALERT;
break;
default:
......@@ -54,22 +54,22 @@ namespace flexisip {
vsyslog(syslev, str, l);
}
void defaultLogHandler(const char *domain, OrtpLogLevel log_level, const char *str, va_list l) {
void defaultLogHandler(const char *domain, BctbxLogLevel log_level, const char *str, va_list l) {
const char *levname = "none";
switch (log_level) {
case ORTP_DEBUG:
case BCTBX_LOG_DEBUG:
levname = "D: ";
break;
case ORTP_MESSAGE:
case BCTBX_LOG_MESSAGE:
levname = "M: ";
break;
case ORTP_WARNING:
case BCTBX_LOG_WARNING:
levname = "W: ";
break;
case ORTP_ERROR:
case BCTBX_LOG_ERROR:
levname = "E: ";
break;
case ORTP_FATAL:
case BCTBX_LOG_FATAL:
levname = "F: ";
break;
default:
......@@ -84,18 +84,17 @@ namespace flexisip {
is_preinit_done = true;
sUseSyslog = syslog;
is_debug = debug;
ortp_set_log_file(stdout);
if (debug) {
ortp_set_log_level_mask(ORTP_LOG_DOMAIN, ORTP_DEBUG | ORTP_MESSAGE | ORTP_WARNING | ORTP_ERROR | ORTP_FATAL);
bctbx_set_log_level_mask(FLEXISIP_LOG_DOMAIN, BCTBX_LOG_DEBUG | BCTBX_LOG_MESSAGE | BCTBX_LOG_WARNING | BCTBX_LOG_ERROR | BCTBX_LOG_FATAL);
} else {
ortp_set_log_level_mask(ORTP_LOG_DOMAIN, ORTP_MESSAGE | ORTP_WARNING | ORTP_ERROR | ORTP_FATAL);
bctbx_set_log_level_mask(FLEXISIP_LOG_DOMAIN, BCTBX_LOG_MESSAGE | BCTBX_LOG_WARNING | BCTBX_LOG_ERROR | BCTBX_LOG_FATAL);
}
if (syslog) {
openlog("flexisip", 0, LOG_USER);
setlogmask(~0);
ortp_set_log_handler(syslogHandler);
bctbx_set_log_handler(syslogHandler);
} else {
//ortp_set_log_handler(defaultLogHandler);
}
......@@ -110,9 +109,9 @@ namespace flexisip {
}
if (debug) {
ortp_set_log_level(ORTP_LOG_DOMAIN, ORTP_DEBUG);
bctbx_set_log_level_mask(FLEXISIP_LOG_DOMAIN, BCTBX_LOG_DEBUG);
} else {
ortp_set_log_level(ORTP_LOG_DOMAIN, ORTP_WARNING);
bctbx_set_log_level_mask(FLEXISIP_LOG_DOMAIN, BCTBX_LOG_WARNING);
}
is_debug = debug;
......@@ -127,7 +126,7 @@ namespace flexisip {
}
void disableGlobally() {
ortp_set_log_level(ORTP_LOG_DOMAIN, ORTP_ERROR);
bctbx_set_log_level_mask(FLEXISIP_LOG_DOMAIN, BCTBX_LOG_ERROR);
}
}
}
......@@ -65,23 +65,22 @@ inline std::basic_istream<CharT, TraitsT> &operator>>(std::basic_istream<CharT,
} //end of namespace log
} //end of namespace flexisip
#define ORTP_DEBUG_MODE 1 // Flexisip extensively use SLOD
#define BCTBX_DEBUG_MODE 1 // Flexisip extensively use SLOD
#ifdef BCTBX_LOG_DOMAIN
#undef BCTBX_LOG_DOMAIN
#endif
#ifndef FLEXISIP_LOG_DOMAIN
#define FLEXISIP_LOG_DOMAIN "flexisip"
#endif
#define BCTBX_LOG_DOMAIN FLEXISIP_LOG_DOMAIN
#include <syslog.h>
#include <ortp/ortp.h>
#include "bctoolbox/logging.h"
#include <ostream>
typedef std::ostream flexisip_record_type;
struct pumpstream : public std::ostringstream {
const OrtpLogLevel level;
pumpstream(OrtpLogLevel l) : level(l) {
}
~pumpstream() {
ortp_log(level, "%s", str().c_str());
}
};
#if (__GNUC__ == 4 && __GNUC_MINOR__ < 5)
template <typename _Tp> inline pumpstream &operator<<(pumpstream &&__os, const _Tp &__x) {
......@@ -89,30 +88,32 @@ template <typename _Tp> inline pumpstream &operator<<(pumpstream &&__os, const _
return __os;
}
#endif
#define SLOGA_FL(file, line) throw FlexisipException() << " " << file << ":" << line << " "
#define SLOG(thelevel) \
if (ortp_log_level_enabled(ORTP_LOG_DOMAIN, (thelevel))) \
pumpstream((thelevel))
#define SLOGD SLOG(ORTP_DEBUG)
#define SLOGI SLOG(ORTP_MESSAGE)
#define SLOGW SLOG(ORTP_WARNING)
#define SLOGE SLOG(ORTP_ERROR)
/*
#define SLOGA SLOGA_FL(__FILE__,__LINE__)
*/
#define SLOG(thelevel) BCTBX_SLOG(FLEXISIP_LOG_DOMAIN,thelevel)
#define SLOGD BCTBX_SLOGD(FLEXISIP_LOG_DOMAIN)
#define SLOGI BCTBX_SLOGI(FLEXISIP_LOG_DOMAIN)
#define SLOGW BCTBX_SLOGW(FLEXISIP_LOG_DOMAIN)
#define SLOGE BCTBX_SLOGE(FLEXISIP_LOG_DOMAIN)
#define LOGV(thelevel, thefmt, theargs) LOGDV((thefmt), (theargs))
#define LOGDV(thefmt, theargs) ortp_logv(ORTP_LOG_DOMAIN, ORTP_DEBUG, (thefmt), (theargs))
#define LOGD ortp_debug
#define LOGI ortp_message
#define LOGW ortp_warning
#define LOGE ortp_error
#define LOGA ortp_fatal
#define LOGDV(thefmt, theargs) bctbx_logv(FLEXISIP_LOG_DOMAIN, BCTBX_LOG_DEBUG, (thefmt), (theargs))
#define LOGD bctbx_debug
#define LOGI bctbx_message
#define LOGW bctbx_warning
#define LOGE bctbx_error
#define LOGA bctbx_fatal
#define LOG_SCOPED_THREAD(key, value)
#define LOGDFN(boolFn, streamFn) \
do { \
if (ortp_log_level_enabled(ORTP_LOG_DOMAIN, (ORTP_DEBUG)) && (boolFn())) { \
pumpstream pump(ORTP_DEBUG); \
if (bctbx_get_log_level_mask(FLEXISIP_LOG_DOMAIN, (BCTBX_LOG_DEBUG)) && (boolFn())) { \
pumpstream pump(BCTBX_LOG_DEBUG); \
(streamFn)(pump); \
} \
} while (0)
......@@ -125,7 +126,7 @@ do {
*/
#define LOGN(args...) \
do { \
ortp_message(args); \
bctbx_message(args); \
if (sUseSyslog) { \
syslog(LOG_NOTICE, args); \
} else { \
......
......@@ -32,7 +32,7 @@
using namespace pidf;
using namespace flexisip;
void _belle_sip_log(belle_sip_log_level lev, const char *fmt, va_list args) {
void _belle_sip_log(const char *domain, BctbxLogLevel lev, const char *fmt, va_list args){
flexisip::log::level level;
switch (lev) {
......@@ -77,7 +77,7 @@ PresenceServer::PresenceServer(std::string configFile) throw(FlexisipException)
, mProvider(belle_sip_stack_create_provider(mStack, NULL))
, mIterateThread(nullptr) {
belle_sip_set_log_handler(_belle_sip_log);
//bctbx_set_log_handler(_belle_sip_log);
belle_sip_set_log_level(BELLE_SIP_LOG_MESSAGE);
xercesc::XMLPlatformUtils::Initialize();
......
......@@ -385,9 +385,9 @@ static string generate_presence_id(void) {
static char presence_id_valid_start_characters[] = ":_abcdefghijklmnopqrstuvwxyz";
char id[7];
int i;
id[0] = presence_id_valid_start_characters[ortp_random() % (sizeof(presence_id_valid_start_characters) - 1)];
id[0] = presence_id_valid_start_characters[belle_sip_random() % (sizeof(presence_id_valid_start_characters) - 1)];
for (i = 1; i < 6; i++) {
id[i] = presence_id_valid_characters[ortp_random() % (sizeof(presence_id_valid_characters) - 1)];
id[i] = presence_id_valid_characters[belle_sip_random() % (sizeof(presence_id_valid_characters) - 1)];
}
id[6] = '\0';
......
bctoolbox @ 8852ed3a
Subproject commit b7dcaa7ec7edd34d5dd37abbe2a5b6a57a9dee53
Subproject commit 8852ed3a237697606f4ffa355edf2a9ed6326640
belle-sip @ 383594e5
Subproject commit 3ff9fc20e71a16f50b58383836fbb47dcb839f26
Subproject commit 383594e5f18090cd67068d84c02b3f8a1371a3e4
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment