diff --git a/daemon/src/account.cpp b/daemon/src/account.cpp
index 8caf47a94ebe3a08142ba360ff453381f8155c87..d9c934158ea3f55fe503053b1f801f4500b7447a 100644
--- a/daemon/src/account.cpp
+++ b/daemon/src/account.cpp
@@ -290,7 +290,7 @@ isCodecValid(const map<string, string> &codec, const vector<map<string, string>
 {
     const map<string, string>::const_iterator name(codec.find(Account::VIDEO_CODEC_NAME));
     if (name == codec.end()) {
-        ERROR("Field \"name\" missing in codec specification");
+        SFL_ERR("Field \"name\" missing in codec specification");
         return false;
     }
 
@@ -302,7 +302,7 @@ isCodecValid(const map<string, string> &codec, const vector<map<string, string>
                 and isFieldValid(codec, Account::VIDEO_CODEC_ENABLED, isBoolean);
         }
     }
-    ERROR("Codec %s not supported", name->second.c_str());
+    SFL_ERR("Codec %s not supported", name->second.c_str());
     return false;
 }
 
@@ -311,7 +311,7 @@ isCodecListValid(const vector<map<string, string> > &list)
 {
     const auto defaults(libav_utils::getDefaultCodecs());
     if (list.size() != defaults.size()) {
-        ERROR("New codec list has a different length than the list of supported codecs");
+        SFL_ERR("New codec list has a different length than the list of supported codecs");
         return false;
     }
 
@@ -445,7 +445,7 @@ Account::getActiveVideoCodecs() const
 #define find_iter()                             \
         const auto iter = details.find(key);    \
         if (iter == details.end()) {            \
-            ERROR("Couldn't find key \"%s\"", key); \
+            SFL_ERR("Couldn't find key \"%s\"", key); \
             return;                             \
         }
 
diff --git a/daemon/src/account_factory.cpp b/daemon/src/account_factory.cpp
index 53dedb4759cb8291ad8812f0e907e0341fc4b3e4..15a94f3288f80bb16fc787743f84f5f6a36fc11d 100644
--- a/daemon/src/account_factory.cpp
+++ b/daemon/src/account_factory.cpp
@@ -52,16 +52,16 @@ AccountFactory::AccountFactory()
 {
     auto sipfunc = [](const std::string& id){ return std::make_shared<SIPAccount>(id, true); };
     generators_.insert(std::make_pair(SIPAccount::ACCOUNT_TYPE, sipfunc));
-    DEBUG("registered %s account", SIPAccount::ACCOUNT_TYPE);
+    SFL_DBG("registered %s account", SIPAccount::ACCOUNT_TYPE);
 #if HAVE_IAX
     auto iaxfunc = [](const std::string& id){ return std::make_shared<IAXAccount>(id); };
     generators_.insert(std::make_pair(IAXAccount::ACCOUNT_TYPE, iaxfunc));
-    DEBUG("registered %s account", IAXAccount::ACCOUNT_TYPE);
+    SFL_DBG("registered %s account", IAXAccount::ACCOUNT_TYPE);
 #endif
 #if HAVE_DHT
     auto dhtfunc = [](const std::string& id){ return std::make_shared<DHTAccount>(id, false); };
     generators_.insert(std::make_pair(DHTAccount::ACCOUNT_TYPE, dhtfunc));
-    DEBUG("registered %s account", DHTAccount::ACCOUNT_TYPE);
+    SFL_DBG("registered %s account", DHTAccount::ACCOUNT_TYPE);
 #endif
 }
 
@@ -70,7 +70,7 @@ AccountFactory::createAccount(const char* const accountType,
                               const std::string& id)
 {
      if (hasAccount(id)) {
-         ERROR("Existing account %s", id.c_str());
+         SFL_ERR("Existing account %s", id.c_str());
          return nullptr;
      }
 
@@ -102,10 +102,10 @@ AccountFactory::removeAccount(Account& account)
 
     std::lock_guard<std::recursive_mutex> lock(mutex_);
     const auto& id = account.getAccountID();
-    DEBUG("Removing account %s", id.c_str());
+    SFL_DBG("Removing account %s", id.c_str());
     auto& map = accountMaps_.at(account.getAccountType());
     map.erase(id);
-    DEBUG("Remaining %u %s account(s)", map.size(), account_type);
+    SFL_DBG("Remaining %u %s account(s)", map.size(), account_type);
 }
 
 void
@@ -116,7 +116,7 @@ AccountFactory::removeAccount(const std::string& id)
     if (auto account = getAccount(id)) {
         removeAccount(*account);
     } else
-        ERROR("No account with ID %s", id.c_str());
+        SFL_ERR("No account with ID %s", id.c_str());
 }
 
 template <> bool
diff --git a/daemon/src/audio/alsa/alsalayer.cpp b/daemon/src/audio/alsa/alsalayer.cpp
index 6a6f9c104af9a14ce70ce5d61cb2496f72490ffc..b0901783e7ede54537c4d1d40d1d66eb02527aae 100644
--- a/daemon/src/audio/alsa/alsalayer.cpp
+++ b/daemon/src/audio/alsa/alsalayer.cpp
@@ -178,7 +178,7 @@ AlsaLayer::~AlsaLayer()
 // Retry approach taken from pa_linux_alsa.c, part of PortAudio
 bool AlsaLayer::openDevice(snd_pcm_t **pcm, const std::string &dev, snd_pcm_stream_t stream)
 {
-    DEBUG("Alsa: Opening %s",  dev.c_str());
+    SFL_DBG("Alsa: Opening %s",  dev.c_str());
 
     static const int MAX_RETRIES = 100;
     int err = snd_pcm_open(pcm, dev.c_str(), stream, 0);
@@ -191,7 +191,7 @@ bool AlsaLayer::openDevice(snd_pcm_t **pcm, const std::string &dev, snd_pcm_stre
     }
 
     if (err < 0) {
-        ERROR("Alsa: couldn't open device %s : %s",  dev.c_str(),
+        SFL_ERR("Alsa: couldn't open device %s : %s",  dev.c_str(),
               snd_strerror(err));
         return false;
     }
@@ -251,7 +251,7 @@ AlsaLayer::stopStream()
 #define ALSA_CALL(call, error) ({ \
         int err_code = call; \
         if (err_code < 0) \
-            ERROR(error ": %s", snd_strerror(err_code)); \
+            SFL_ERR(error ": %s", snd_strerror(err_code)); \
             err_code; \
         })
 
@@ -365,8 +365,8 @@ bool AlsaLayer::alsa_set_params(snd_pcm_t *pcm_handle)
     snd_pcm_hw_params_get_buffer_size_max(hwparams, &buffer_size_max);
     snd_pcm_hw_params_get_period_size_min(hwparams, &period_size_min, nullptr);
     snd_pcm_hw_params_get_period_size_max(hwparams, &period_size_max, nullptr);
-    DEBUG("Buffer size range from %lu to %lu", buffer_size_min, buffer_size_max);
-    DEBUG("Period size range from %lu to %lu", period_size_min, period_size_max);
+    SFL_DBG("Buffer size range from %lu to %lu", buffer_size_min, buffer_size_max);
+    SFL_DBG("Period size range from %lu to %lu", period_size_min, period_size_max);
     buffer_size = buffer_size > buffer_size_max ? buffer_size_max : buffer_size;
     buffer_size = buffer_size < buffer_size_min ? buffer_size_min : buffer_size;
     period_size = period_size > period_size_max ? period_size_max : period_size;
@@ -381,17 +381,17 @@ bool AlsaLayer::alsa_set_params(snd_pcm_t *pcm_handle)
     snd_pcm_hw_params_get_period_size(hwparams, &period_size, nullptr);
     snd_pcm_hw_params_get_rate(hwparams, &audioFormat_.sample_rate, nullptr);
     snd_pcm_hw_params_get_channels(hwparams, &audioFormat_.nb_channels);
-    DEBUG("Was set period_size = %lu", period_size);
-    DEBUG("Was set buffer_size = %lu", buffer_size);
+    SFL_DBG("Was set period_size = %lu", period_size);
+    SFL_DBG("Was set buffer_size = %lu", buffer_size);
 
     if (2 * period_size > buffer_size) {
-        ERROR("buffer to small, could not use");
+        SFL_ERR("buffer to small, could not use");
         return false;
     }
 
 #undef HW
 
-    DEBUG("%s using format %s",
+    SFL_DBG("%s using format %s",
           (snd_pcm_stream(pcm_handle) == SND_PCM_STREAM_PLAYBACK) ? "playback" : "capture",
           audioFormat_.toString().c_str() );
 
@@ -451,12 +451,12 @@ AlsaLayer::write(SFLAudioSample* buffer, int frames, snd_pcm_t * handle)
 
             if (ALSA_CALL(snd_pcm_status(handle, status), "Cannot get playback handle status") >= 0) {
                 if (snd_pcm_status_get_state(status) == SND_PCM_STATE_SETUP) {
-                    ERROR("Writing in state SND_PCM_STATE_SETUP, should be "
+                    SFL_ERR("Writing in state SND_PCM_STATE_SETUP, should be "
                           "SND_PCM_STATE_PREPARED or SND_PCM_STATE_RUNNING");
                     int error = snd_pcm_prepare(handle);
 
                     if (error < 0) {
-                        ERROR("Failed to prepare handle: %s", snd_strerror(error));
+                        SFL_ERR("Failed to prepare handle: %s", snd_strerror(error));
                         stopPlaybackStream();
                     }
                 }
@@ -466,7 +466,7 @@ AlsaLayer::write(SFLAudioSample* buffer, int frames, snd_pcm_t * handle)
         }
 
         default:
-            ERROR("Unknown write error, dropping frames: %s", snd_strerror(err));
+            SFL_ERR("Unknown write error, dropping frames: %s", snd_strerror(err));
             stopPlaybackStream();
             break;
     }
@@ -499,12 +499,12 @@ AlsaLayer::read(SFLAudioSample* buffer, int frames)
                     startCaptureStream();
                 }
 
-            ERROR("XRUN capture ignored (%s)", snd_strerror(err));
+            SFL_ERR("XRUN capture ignored (%s)", snd_strerror(err));
             break;
         }
 
         case -EPERM:
-            ERROR("Can't capture, EPERM (%s)", snd_strerror(err));
+            SFL_ERR("Can't capture, EPERM (%s)", snd_strerror(err));
             prepareCaptureStream();
             startCaptureStream();
             break;
@@ -536,7 +536,7 @@ safeUpdate(snd_pcm_t *handle, int &samples)
         samples = snd_pcm_recover(handle, samples, 0);
 
         if (samples < 0) {
-            ERROR("Got unrecoverable error from snd_pcm_avail_update: %s", snd_strerror(samples));
+            SFL_ERR("Got unrecoverable error from snd_pcm_avail_update: %s", snd_strerror(samples));
             return false;
         }
     }
@@ -596,11 +596,11 @@ AlsaLayer::getAudioDeviceIndexMap(bool getCapture) const
                 int err;
 
                 if ((err = snd_ctl_pcm_info(handle, pcminfo)) < 0) {
-                    WARN("Cannot get info for %s %s: %s", getCapture ?
+                    SFL_WARN("Cannot get info for %s %s: %s", getCapture ?
                          "capture device" : "playback device", name.c_str(),
                          snd_strerror(err));
                 } else {
-                    DEBUG("card %i : %s [%s]",
+                    SFL_DBG("card %i : %s [%s]",
                           numCard,
                           snd_ctl_card_info_get_id(info),
                           snd_ctl_card_info_get_name(info));
@@ -671,7 +671,7 @@ AlsaLayer::getAudioDeviceName(int index, DeviceType type) const
             return getCaptureDeviceList().at(index);
         default:
             // Should never happen
-            ERROR("Unexpected type");
+            SFL_ERR("Unexpected type");
             return "";
     }
 }
@@ -683,7 +683,7 @@ void AlsaLayer::capture()
     int toGetFrames = snd_pcm_avail_update(captureHandle_);
 
     if (toGetFrames < 0)
-        ERROR("Audio: Mic error: %s", snd_strerror(toGetFrames));
+        SFL_ERR("Audio: Mic error: %s", snd_strerror(toGetFrames));
 
     if (toGetFrames <= 0)
         return;
@@ -693,7 +693,7 @@ void AlsaLayer::capture()
     captureIBuff_.resize(toGetFrames * audioFormat_.nb_channels);
 
     if (read(captureIBuff_.data(), toGetFrames) != toGetFrames) {
-        ERROR("ALSA MIC : Couldn't read!");
+        SFL_ERR("ALSA MIC : Couldn't read!");
         return;
     }
 
@@ -818,7 +818,7 @@ void AlsaLayer::audioCallback()
         playbackBuff_.resize(ringtoneAvailFrames);
 
         if (file_tone) {
-            DEBUG("playback gain %d", playbackGain_);
+            SFL_DBG("playback gain %d", playbackGain_);
             file_tone->getNext(playbackBuff_, playbackGain_);
         }
 
diff --git a/daemon/src/audio/audiobuffer.cpp b/daemon/src/audio/audiobuffer.cpp
index 51eac48567ac6c069db7b8a860efce5fabf45a25..26b843ec6f07c771262bb5ac4d50c357b7e563c9 100644
--- a/daemon/src/audio/audiobuffer.cpp
+++ b/daemon/src/audio/audiobuffer.cpp
@@ -112,7 +112,7 @@ void AudioBuffer::setChannelNum(unsigned n, bool mix /* = false */)
         return;
     }
 
-    WARN("Unsupported channel mixing: %dch->%dch", c, n);
+    SFL_WARN("Unsupported channel mixing: %dch->%dch", c, n);
     samples_.resize(n, samples_[0]);
 }
 
@@ -137,7 +137,7 @@ std::vector<SFLAudioSample> * AudioBuffer::getChannel(unsigned chan /* = 0 */)
     if (chan < samples_.size())
         return &samples_[chan];
 
-    ERROR("Audio channel %u out of range", chan);
+    SFL_ERR("Audio channel %u out of range", chan);
     return nullptr;
 }
 
@@ -147,7 +147,7 @@ void AudioBuffer::applyGain(double gain)
 
     const double g = std::max(std::min(1.0, gain), -1.0);
     if (g != gain)
-        DEBUG("Normalizing %f to [-1.0, 1.0]", gain);
+        SFL_DBG("Normalizing %f to [-1.0, 1.0]", gain);
 
     for (auto &channel : samples_)
         for (auto &sample : channel)
diff --git a/daemon/src/audio/audiolayer.cpp b/daemon/src/audio/audiolayer.cpp
index ee1eabcf84f6ce716152adc16c2ae75de0211439..30b65a4c8c5de972b49c2b224037607a87906a3e 100644
--- a/daemon/src/audio/audiolayer.cpp
+++ b/daemon/src/audio/audiolayer.cpp
@@ -62,7 +62,7 @@ AudioLayer::~AudioLayer()
 void AudioLayer::hardwareFormatAvailable(AudioFormat playback)
 {
     std::lock_guard<std::mutex> lock(mutex_);
-    DEBUG("hardwareFormatAvailable : %s", playback.toString().c_str());
+    SFL_DBG("hardwareFormatAvailable : %s", playback.toString().c_str());
     urgentRingBuffer_.setFormat(playback);
     resampler_->setFormat(playback);
     Manager::instance().hardwareAudioFormatChanged(playback);
diff --git a/daemon/src/audio/audioloop.cpp b/daemon/src/audio/audioloop.cpp
index 50f52a090d4b10628a139b686dfac11869d69139..f982a866a4f822ba9e1a73c6e6dc5d0b7165c55f 100644
--- a/daemon/src/audio/audioloop.cpp
+++ b/daemon/src/audio/audioloop.cpp
@@ -65,7 +65,7 @@ void
 AudioLoop::getNext(AudioBuffer& output, double gain)
 {
     if (!buffer_) {
-        ERROR("buffer is NULL");
+        SFL_ERR("buffer is NULL");
         return;
     }
 
@@ -75,10 +75,10 @@ AudioLoop::getNext(AudioBuffer& output, double gain)
     size_t output_pos = 0;
 
     if (buf_samples == 0) {
-        ERROR("Audio loop size is 0");
+        SFL_ERR("Audio loop size is 0");
         return;
     } else if (pos >= buf_samples) {
-        ERROR("Invalid loop position %d", pos);
+        SFL_ERR("Invalid loop position %d", pos);
         return;
     }
 
diff --git a/daemon/src/audio/audiorecord.cpp b/daemon/src/audio/audiorecord.cpp
index 31e88fdd2a5925ae05f44e151296b49fc1c10f86..c2070f08cf48334eb464f9137e0f477d323db367 100644
--- a/daemon/src/audio/audiorecord.cpp
+++ b/daemon/src/audio/audiorecord.cpp
@@ -96,7 +96,7 @@ AudioRecord::AudioRecord() : fileHandle_(nullptr)
     , filename_(createFilename())
     , savePath_()
 {
-    WARN("Generate filename for this call %s ", filename_.c_str());
+    SFL_WARN("Generate filename for this call %s ", filename_.c_str());
 }
 
 AudioRecord::~AudioRecord()
@@ -144,7 +144,7 @@ void AudioRecord::initFilename(const std::string &peerNumber)
     fName.append("-" + sanitize(peerNumber) + "-" PACKAGE);
 
     if (filename_.find(".wav") == std::string::npos) {
-        DEBUG("Concatenate .wav file extension: name : %s", filename_.c_str());
+        SFL_DBG("Concatenate .wav file extension: name : %s", filename_.c_str());
         fName.append(".wav");
     }
 
@@ -163,19 +163,19 @@ bool AudioRecord::openFile()
     const bool doAppend = fileExists();
     const int access = doAppend ? SFM_RDWR : SFM_WRITE;
 
-    DEBUG("Opening file %s with format %s", savePath_.c_str(), sndFormat_.toString().c_str());
+    SFL_DBG("Opening file %s with format %s", savePath_.c_str(), sndFormat_.toString().c_str());
     fileHandle_ = new SndfileHandle(savePath_.c_str(), access, SF_FORMAT_WAV | SF_FORMAT_PCM_16, sndFormat_.nb_channels, sndFormat_.sample_rate);
 
     // check overloaded boolean operator
     if (!*fileHandle_) {
-        WARN("Could not open WAV file!");
+        SFL_WARN("Could not open WAV file!");
         delete fileHandle_;
         fileHandle_ = 0;
         return false;
     }
 
     if (doAppend and fileHandle_->seek(0, SEEK_END) < 0)
-        WARN("Couldn't seek to the end of the file ");
+        SFL_WARN("Couldn't seek to the end of the file ");
 
     return result;
 }
@@ -215,7 +215,7 @@ bool AudioRecord::toggleRecording()
 
 void AudioRecord::stopRecording()
 {
-    DEBUG("Stop recording");
+    SFL_DBG("Stop recording");
     recordingEnabled_ = false;
 }
 
@@ -225,14 +225,14 @@ void AudioRecord::recData(AudioBuffer& buffer)
         return;
 
     if (fileHandle_ == 0) {
-        DEBUG("Can't record data, a file has not yet been opened!");
+        SFL_DBG("Can't record data, a file has not yet been opened!");
         return;
     }
 
     auto interleaved = buffer.interleave();
     const int nSamples = interleaved.size();
     if (fileHandle_->write(interleaved.data(), nSamples) != nSamples) {
-        WARN("Could not record data!");
+        SFL_WARN("Could not record data!");
     } else {
         fileHandle_->writeSync();
     }
diff --git a/daemon/src/audio/audiortp/audio_rtp_factory.cpp b/daemon/src/audio/audiortp/audio_rtp_factory.cpp
index 53f2dffec24a4c845092a49b09277f6134ed625e..bda5c8ad2a987c722ad2a95bff7b541bdc19edf0 100644
--- a/daemon/src/audio/audiortp/audio_rtp_factory.cpp
+++ b/daemon/src/audio/audiortp/audio_rtp_factory.cpp
@@ -225,7 +225,7 @@ void AudioRtpFactory::setRemoteCryptoInfo(SdesNegotiator& nego)
             throw AudioRtpFactoryException(e.what());
         }
     } else {
-        ERROR("Should not store remote crypto info for non-SDES sessions");
+        SFL_ERR("Should not store remote crypto info for non-SDES sessions");
     }
 }
 
diff --git a/daemon/src/audio/audiortp/audio_rtp_session.cpp b/daemon/src/audio/audiortp/audio_rtp_session.cpp
index dc6050bdd45e17214f22d2e76b68a1b739c60a15..dbdfda1076aae0bcfc8f16fbecd9aa84edfa0d46 100644
--- a/daemon/src/audio/audiortp/audio_rtp_session.cpp
+++ b/daemon/src/audio/audiortp/audio_rtp_session.cpp
@@ -105,13 +105,13 @@ void AudioRtpSession::setSessionMedia(const std::vector<AudioCodec*> &audioCodec
     }
 
     transportRate_ = rtpStream_.getTransportRate();
-    DEBUG("Switching to a transport rate of %d ms", transportRate_);
+    SFL_DBG("Switching to a transport rate of %d ms", transportRate_);
 }
 
 void AudioRtpSession::sendDtmfEvent()
 {
     DTMFEvent &dtmf(dtmfQueue_.front());
-    DEBUG("Send RTP Dtmf (%d)", dtmf.payload.event);
+    SFL_DBG("Send RTP Dtmf (%d)", dtmf.payload.event);
 
     const int increment = getIncrementForDTMF();
     if (dtmf.newevent)
@@ -181,7 +181,7 @@ void AudioRtpSession::receiveSpeakerData()
         const double jit_mean = std::accumulate(rxJitters_.begin(), rxJitters_.end(), 0.0) / rxJitters_.size();
         const double jit_sq_sum = std::inner_product(rxJitters_.begin(), rxJitters_.end(), rxJitters_.begin(), 0.0);
         const double jit_stdev = std::sqrt(jit_sq_sum / rxJitters_.size() - jit_mean * jit_mean);
-        DEBUG("Jitter avg: %fms std dev %fms", jit_mean, jit_stdev);
+        SFL_DBG("Jitter avg: %fms std dev %fms", jit_mean, jit_stdev);
         jitterReportInterval_ = 0;
     }
 #endif
@@ -193,13 +193,13 @@ void AudioRtpSession::receiveSpeakerData()
         rxLastSeqNum_ += seqNumDiff;
         seqNumDiff = 1;
     } else if (seqNumDiff < 0) {
-        DEBUG("Dropping out-of-order packet %d (last %d)", rxLastSeqNum_ + seqNumDiff, rxLastSeqNum_);
+        SFL_DBG("Dropping out-of-order packet %d (last %d)", rxLastSeqNum_ + seqNumDiff, rxLastSeqNum_);
         return;
     } else {
         rxLastSeqNum_ += seqNumDiff;
     }
     if (rxLastSeqNum_ && seqNumDiff > 1) {
-        DEBUG("%d packets lost", seqNumDiff-1);
+        SFL_DBG("%d packets lost", seqNumDiff-1);
         for (unsigned i = 0, n = seqNumDiff - 1; i < n; i++)
             rtpStream_.processDataDecode(nullptr, 0, adu->getType());
     }
@@ -241,7 +241,7 @@ void AudioRtpSession::setSessionTimeouts()
 {
     const unsigned schedulingTimeout = 4000;
     const unsigned expireTimeout = 1000000;
-    DEBUG("Set session scheduling timeout (%d) and expireTimeout (%d)",
+    SFL_DBG("Set session scheduling timeout (%d) and expireTimeout (%d)",
           schedulingTimeout, expireTimeout);
 
     queue_.setSchedulingTimeout(schedulingTimeout);
@@ -250,7 +250,7 @@ void AudioRtpSession::setSessionTimeouts()
 
 void AudioRtpSession::updateDestinationIpAddress()
 {
-    DEBUG("Update destination ip address");
+    SFL_DBG("Update destination ip address");
 
     // Destination address are stored in a list in ccrtp
     // This method remove the current destination entry
@@ -258,28 +258,28 @@ void AudioRtpSession::updateDestinationIpAddress()
 #if HAVE_IPV6
      && !(remoteIp_.isIpv6() == AF_INET6 && queue_.forgetDestination(static_cast<ost::IPV6Host>(remoteIp_), remoteIp_.getPort()))
 #endif
-    ) DEBUG("Did not remove previous destination");
+    ) SFL_DBG("Did not remove previous destination");
 
     IpAddr remote = {call_.getLocalSDP().getRemoteIP()};
     remote.setPort(call_.getLocalSDP().getRemoteAudioPort());
     if (!remote) {
-        WARN("Target IP address (%s) is not correct!", call_.getLocalSDP().getRemoteIP().c_str());
+        SFL_WARN("Target IP address (%s) is not correct!", call_.getLocalSDP().getRemoteIP().c_str());
         return;
     }
     remoteIp_ = remote;
-    DEBUG("New remote address for session: %s", remote.toString(true).c_str());
+    SFL_DBG("New remote address for session: %s", remote.toString(true).c_str());
 
     if (!(remoteIp_.isIpv4()  && queue_.addDestination(static_cast<ost::IPV4Host>(remoteIp_), remoteIp_.getPort()))
 #if HAVE_IPV6
      && !(remoteIp_.isIpv6() && queue_.addDestination(static_cast<ost::IPV6Host>(remoteIp_), remoteIp_.getPort()))
 #endif
-    ) WARN("Can't add new destination to session!");
+    ) SFL_WARN("Can't add new destination to session!");
 }
 
 
 void AudioRtpSession::prepareRtpReceiveThread(const std::vector<AudioCodec*> &audioCodecs)
 {
-    DEBUG("Preparing receiving thread");
+    SFL_DBG("Preparing receiving thread");
     isStarted_ = true;
 #ifdef RTP_DEBUG
     rxLast_ = std::chrono::high_resolution_clock::now();
@@ -336,13 +336,13 @@ void AudioRtpSession::putDtmfEvent(char digit)
 CachedAudioRtpState *
 AudioRtpSession::saveState() const
 {
-    ERROR("Not implemented");
+    SFL_ERR("Not implemented");
     return nullptr;
 }
 
 void
 AudioRtpSession::restoreState(const CachedAudioRtpState &state UNUSED)
 {
-    ERROR("Not implemented");
+    SFL_ERR("Not implemented");
 }
 }
diff --git a/daemon/src/audio/audiortp/audio_rtp_stream.cpp b/daemon/src/audio/audiortp/audio_rtp_stream.cpp
index 1e64ee3440807854771cf3c44301721dbb1b99eb..ee9fb1bed2b68a390e9594fd5305ae1c04104185 100644
--- a/daemon/src/audio/audiortp/audio_rtp_stream.cpp
+++ b/daemon/src/audio/audiortp/audio_rtp_stream.cpp
@@ -97,7 +97,7 @@ sfl::AudioCodec *
 AudioRtpStream::getCurrentEncoder() const
 {
     if (audioCodecs_.empty() or currentEncoderIndex_ >= audioCodecs_.size()) {
-        ERROR("No codec found");
+        SFL_ERR("No codec found");
         return nullptr;
     }
 
@@ -108,7 +108,7 @@ sfl::AudioCodec *
 AudioRtpStream::getCurrentDecoder() const
 {
     if (audioCodecs_.empty() or currentDecoderIndex_ >= audioCodecs_.size()) {
-        ERROR("No codec found");
+        SFL_ERR("No codec found");
         return nullptr;
     }
 
@@ -141,10 +141,10 @@ bool AudioRtpStream::tryToSwitchDecoder(int newPt)
         hasDynamicPayloadType_ = codec->hasDynamicPayload();
         resetDecoderPLC(codec);
         currentDecoderIndex_ = i; // FIXME: this is not reliable
-        DEBUG("Switched payload type to %d", newPt);
+        SFL_DBG("Switched payload type to %d", newPt);
         return true;
     }
-    ERROR("Could not switch payload types");
+    SFL_ERR("Could not switch payload types");
     return false;
 }
 
@@ -243,7 +243,7 @@ void AudioRtpStream::setRtpMedia(const std::vector<AudioCodec*> &audioCodecs)
     if (audioCodecs.empty()) {
         codecEncMutex_.unlock();
         codecDecMutex_.unlock();
-        ERROR("Audio codecs empty");
+        SFL_ERR("Audio codecs empty");
         return;
     }
 
@@ -317,7 +317,7 @@ size_t AudioRtpStream::processDataEncode()
     const size_t samples = Manager::instance().getRingBufferPool().getData(micData_, id_);
 
     if (samples != samplesToGet) {
-        ERROR("Asked for %d samples from bindings on call '%s', got %d",
+        SFL_ERR("Asked for %d samples from bindings on call '%s', got %d",
               samplesToGet, id_.c_str(), samples);
         return 0;
     }
@@ -325,7 +325,7 @@ size_t AudioRtpStream::processDataEncode()
     AudioBuffer *out = &micData_;
     if (encoder_.format_.sample_rate != mainBuffFormat.sample_rate) {
         if (!encoder_.resampler_) {
-            ERROR("Resampler already destroyed");
+            SFL_ERR("Resampler already destroyed");
             return 0;
         }
         encoder_.resampledData_.setChannelNum(mainBuffFormat.nb_channels);
@@ -344,7 +344,7 @@ size_t AudioRtpStream::processDataEncode()
         std::lock_guard<std::mutex> lock(codecEncMutex_);
         auto codec = getCurrentEncoder();
         if (!codec) {
-            ERROR("Audio codec already destroyed");
+            SFL_ERR("Audio codec already destroyed");
             return 0;
         }
 
@@ -373,7 +373,7 @@ void AudioRtpStream::processDataDecode(unsigned char *spkrData, size_t size, int
         if (not switched) {
             if (!warningInterval_) {
                 warningInterval_ = 250;
-                WARN("Invalid payload type %d, expected %d", payloadType, decPt);
+                SFL_WARN("Invalid payload type %d, expected %d", payloadType, decPt);
             }
 
             warningInterval_--;
@@ -387,7 +387,7 @@ void AudioRtpStream::processDataDecode(unsigned char *spkrData, size_t size, int
         std::lock_guard<std::mutex> lock(codecDecMutex_);
         auto codec = getCurrentDecoder();
         if (!codec) {
-            ERROR("Audio codec already destroyed");
+            SFL_ERR("Audio codec already destroyed");
             return;
         }
         if (spkrData) { // Packet is available
@@ -421,7 +421,7 @@ void AudioRtpStream::processDataDecode(unsigned char *spkrData, size_t size, int
     AudioFormat mainBuffFormat = Manager::instance().getRingBufferPool().getInternalAudioFormat();
     if (decFormat.sample_rate != mainBuffFormat.sample_rate) {
         if (!decoder_.resampler_) {
-            ERROR("Resampler already destroyed");
+            SFL_ERR("Resampler already destroyed");
             return;
         }
         decoder_.resampledData_.setChannelNum(decFormat.nb_channels);
diff --git a/daemon/src/audio/audiortp/audio_srtp_session.cpp b/daemon/src/audio/audiortp/audio_srtp_session.cpp
index 193898e4a115180310ecec0b09a1366582ea2801..02f9c5e07f9f5bc6b3bd535ee4b79af864694a54 100644
--- a/daemon/src/audio/audiortp/audio_srtp_session.cpp
+++ b/daemon/src/audio/audiortp/audio_srtp_session.cpp
@@ -73,7 +73,7 @@ decodeBase64(unsigned char *input, int length)
 static void
 bufferFillMasterKey(std::vector<uint8_t>& dest)
 {
-    DEBUG("Init local master key");
+    SFL_DBG("Init local master key");
     std::uniform_int_distribution<uint8_t> rand_byte(0, 255);
 
     // Fill the key
@@ -87,7 +87,7 @@ bufferFillMasterKey(std::vector<uint8_t>& dest)
 static void
 bufferFillMasterSalt(std::vector<uint8_t>& dest)
 {
-    DEBUG("Init local master salt");
+    SFL_DBG("Init local master salt");
     std::uniform_int_distribution<uint8_t> rand_byte(0, 255);
 
     // Fill the key
@@ -123,7 +123,7 @@ AudioSrtpSession::~AudioSrtpSession()
 
 void AudioSrtpSession::initLocalCryptoInfo()
 {
-    DEBUG("AudioSrtpSession: Set cryptographic info for this rtp session");
+    SFL_DBG("AudioSrtpSession: Set cryptographic info for this rtp session");
 
     // Initialize local Crypto context
     initializeLocalMasterKey();
@@ -138,7 +138,7 @@ void AudioSrtpSession::initLocalCryptoInfo()
 
 void AudioSrtpSession::initLocalCryptoInfoOnOffhold()
 {
-    DEBUG("AudioSrtpSession: Set cryptographic info for this rtp session");
+    SFL_DBG("AudioSrtpSession: Set cryptographic info for this rtp session");
 
     // Initialize local Crypto context
     initializeLocalCryptoContext();
@@ -151,7 +151,7 @@ void AudioSrtpSession::initLocalCryptoInfoOnOffhold()
 
 std::vector<std::string> AudioSrtpSession::getLocalCryptoInfo()
 {
-    DEBUG("Get Cryptographic info from this rtp session");
+    SFL_DBG("Get Cryptographic info from this rtp session");
 
     std::vector<std::string> crypto_vector;
 
@@ -173,7 +173,7 @@ std::vector<std::string> AudioSrtpSession::getLocalCryptoInfo()
     crypto_attr += crypto_suite.append(" ");
     crypto_attr += srtp_keys;
 
-    DEBUG("%s", crypto_attr.c_str());
+    SFL_DBG("%s", crypto_attr.c_str());
 
     crypto_vector.push_back(crypto_attr);
 
@@ -219,7 +219,7 @@ void AudioSrtpSession::initializeLocalMasterSalt()
 
 std::string AudioSrtpSession::getBase64ConcatenatedKeys()
 {
-    DEBUG("Get base64 concatenated keys");
+    SFL_DBG("Get base64 concatenated keys");
 
     // compute concatenated master and salt length
     std::vector<uint8> concatKeys;
@@ -255,7 +255,7 @@ void AudioSrtpSession::unBase64ConcatenatedKeys(std::string base64keys)
 
 void AudioSrtpSession::initializeRemoteCryptoContext()
 {
-    DEBUG("Initialize remote crypto context");
+    SFL_DBG("Initialize remote crypto context");
 
     const CryptoSuiteDefinition &crypto = sfl::CryptoSuites[remoteCryptoSuite_];
 
@@ -279,7 +279,7 @@ void AudioSrtpSession::initializeRemoteCryptoContext()
 
 void AudioSrtpSession::initializeLocalCryptoContext()
 {
-    DEBUG("Initialize local crypto context");
+    SFL_DBG("Initialize local crypto context");
 
     const CryptoSuiteDefinition &crypto = sfl::CryptoSuites[localCryptoSuite_];
 
diff --git a/daemon/src/audio/audiortp/audio_symmetric_rtp_session.cpp b/daemon/src/audio/audiortp/audio_symmetric_rtp_session.cpp
index 7cad90da03429d3bf8fd319ca462fd22ff50c4c4..2155f281b690c0e8364b766c15957028e4cef1c3 100644
--- a/daemon/src/audio/audiortp/audio_symmetric_rtp_session.cpp
+++ b/daemon/src/audio/audiortp/audio_symmetric_rtp_session.cpp
@@ -44,7 +44,7 @@ AudioSymmetricRtpSession::AudioSymmetricRtpSession(SIPCall &call) :
     ost::SymmetricRTPSession(static_cast<ost::IPV4Host>(call.getLocalIp()), call.getLocalAudioPort())
     , AudioRtpSession(call, *this)
 {
-    DEBUG("Setting new RTP session with destination %s:%d",
+    SFL_DBG("Setting new RTP session with destination %s:%d",
           call_.getLocalIp().toString().c_str(), call_.getLocalAudioPort());
 }
 
@@ -78,17 +78,17 @@ void AudioSymmetricRtpSession::onGotRR(ost::SyncSource& source, ost::RTCPCompoun
 {
     ost::SymmetricRTPSession::onGotRR(source, RR, blocks);
 #ifdef RTP_DEBUG
-    DEBUG("onGotRR");
-    DEBUG("Unpacking %d blocks",blocks);
+    SFL_DBG("onGotRR");
+    SFL_DBG("Unpacking %d blocks",blocks);
     for (int i = 0; i < blocks; ++i)
     {
-        DEBUG("fractionLost : %hhu", RR.blocks[i].rinfo.fractionLost);
-        DEBUG("lostMSB : %hhu", RR.blocks[i].rinfo.lostMSB);
-        DEBUG("lostLSW : %hu", RR.blocks[i].rinfo.lostLSW);
-        DEBUG("highestSeqNum : %u", RR.blocks[i].rinfo.highestSeqNum);
-        DEBUG("jitter : %u", RR.blocks[i].rinfo.jitter);
-        DEBUG("lsr : %u", RR.blocks[i].rinfo.lsr);
-        DEBUG("dlsr : %u", RR.blocks[i].rinfo.dlsr);
+        SFL_DBG("fractionLost : %hhu", RR.blocks[i].rinfo.fractionLost);
+        SFL_DBG("lostMSB : %hhu", RR.blocks[i].rinfo.lostMSB);
+        SFL_DBG("lostLSW : %hu", RR.blocks[i].rinfo.lostLSW);
+        SFL_DBG("highestSeqNum : %u", RR.blocks[i].rinfo.highestSeqNum);
+        SFL_DBG("jitter : %u", RR.blocks[i].rinfo.jitter);
+        SFL_DBG("lsr : %u", RR.blocks[i].rinfo.lsr);
+        SFL_DBG("dlsr : %u", RR.blocks[i].rinfo.dlsr);
      }
 #endif
 }
@@ -97,7 +97,7 @@ void AudioSymmetricRtpSession::onGotRR(ost::SyncSource& source, ost::RTCPCompoun
 void AudioSymmetricRtpSession::onGotSR(ost::SyncSource& source, ost::RTCPCompoundHandler::SendReport& SR, uint8 blocks)
 {
 #ifdef RTP_DEBUG
-    DEBUG("onGotSR");
+    SFL_DBG("onGotSR");
     std::cout << "I got an SR RTCP report from "
             << std::hex << (int)source.getID() << "@"
             << std::dec
@@ -148,19 +148,19 @@ void AudioSymmetricRtpSession::onGotSR(ost::SyncSource& source, ost::RTCPCompoun
         stats["DLSR"] = receiver_report.getDelayLastSR();
 
 #ifdef RTP_DEBUG
-        DEBUG("lastSR NTPTimestamp : %lu", receiver_report.getLastSRNTPTimestampFrac() << 16);
-        DEBUG("NTPTimestampFrac : %lu", timestampFrac);
-        DEBUG("rttMSW : %u", rttMSW);
-        DEBUG("rttLSW : %u", rttLSW);
-        DEBUG("RTT recomposed: %lu", rtt);
-        DEBUG("LDSR: %lu", receiver_report.getDelayLastSR());
-        DEBUG("Packet count : %u", stats["PACKET_COUNT"]);
-        DEBUG("Fraction packet loss : %.2f", (double) stats["PACKET_LOSS"] * 100 / 256);
-        DEBUG("Cumulative packet loss : %d", stats["CUMUL_PACKET_LOSS"]);
-        DEBUG("HighestSeqNum : %u", stats["HIGH_SEC_NUM"]);
-        DEBUG("Jitter : %u", stats["JITTER"]);
-        DEBUG("RTT : %.2f", (double) stats["RTT"] / 65536);
-        DEBUG("Delay since last report %.2f seconds", (double) stats["DLSR"] / 65536.0);
+        SFL_DBG("lastSR NTPTimestamp : %lu", receiver_report.getLastSRNTPTimestampFrac() << 16);
+        SFL_DBG("NTPTimestampFrac : %lu", timestampFrac);
+        SFL_DBG("rttMSW : %u", rttMSW);
+        SFL_DBG("rttLSW : %u", rttLSW);
+        SFL_DBG("RTT recomposed: %lu", rtt);
+        SFL_DBG("LDSR: %lu", receiver_report.getDelayLastSR());
+        SFL_DBG("Packet count : %u", stats["PACKET_COUNT"]);
+        SFL_DBG("Fraction packet loss : %.2f", (double) stats["PACKET_LOSS"] * 100 / 256);
+        SFL_DBG("Cumulative packet loss : %d", stats["CUMUL_PACKET_LOSS"]);
+        SFL_DBG("HighestSeqNum : %u", stats["HIGH_SEC_NUM"]);
+        SFL_DBG("Jitter : %u", stats["JITTER"]);
+        SFL_DBG("RTT : %.2f", (double) stats["RTT"] / 65536);
+        SFL_DBG("Delay since last report %.2f seconds", (double) stats["DLSR"] / 65536.0);
 #endif
         Manager::instance().getClient()->getCallManager()->onRtcpReportReceived(call_.getCallId(), stats);
     }
@@ -172,7 +172,7 @@ AudioSymmetricRtpSessionIPv6::AudioSymmetricRtpSessionIPv6(SIPCall &call) :
     ost::SymmetricRTPSessionIPV6(static_cast<ost::IPV6Host>(call.getLocalIp()), call.getLocalAudioPort())
     , AudioRtpSession(call, *this)
 {
-    DEBUG("Setting new RTP/IPv6 session with destination %s:%d",
+    SFL_DBG("Setting new RTP/IPv6 session with destination %s:%d",
           call_.getLocalIp().toString().c_str(), call_.getLocalAudioPort());
 }
 
@@ -224,9 +224,9 @@ size_t
 AudioSymmetricRtpSessionIPv6::recvData(unsigned char* buffer, size_t len, ost::IPV4Host&, ost::tpport_t& port)
 {
     ost::IPV6Host hostv6 = call_.getLocalIp();
-    ERROR("recvData %d ", hostv6.getAddressCount());
+    SFL_ERR("recvData %d ", hostv6.getAddressCount());
     size_t r = ost::SymmetricRTPSessionIPV6::recvData(buffer, len, hostv6, port);
-    ERROR("recvData from %s %d called in ipv6 stack, size %d", IpAddr(hostv6.getAddress()).toString().c_str(), port, len);
+    SFL_ERR("recvData from %s %d called in ipv6 stack, size %d", IpAddr(hostv6.getAddress()).toString().c_str(), port, len);
     return r;
 }
 
@@ -235,7 +235,7 @@ AudioSymmetricRtpSessionIPv6::recvControl(unsigned char* buffer, size_t len, ost
 {
     ost::IPV6Host hostv6 = call_.getLocalIp();
     size_t r = ost::SymmetricRTPSessionIPV6::recvControl(buffer, len, hostv6, port);
-    ERROR("recvControl from %s %d called in ipv6 stack, size %d", IpAddr(hostv6.getAddress()).toString().c_str(), port, len);
+    SFL_ERR("recvControl from %s %d called in ipv6 stack, size %d", IpAddr(hostv6.getAddress()).toString().c_str(), port, len);
     return r;
 }
 
diff --git a/daemon/src/audio/audiortp/audio_zrtp_session.cpp b/daemon/src/audio/audiortp/audio_zrtp_session.cpp
index 35da4607491c420f1e6378b828fed5e4938dda21..b2bd6fa75b7f5b93b8ecda8b2e2ef1f5f0736b3e 100644
--- a/daemon/src/audio/audiortp/audio_zrtp_session.cpp
+++ b/daemon/src/audio/audiortp/audio_zrtp_session.cpp
@@ -55,7 +55,7 @@ AudioZrtpSession::AudioZrtpSession(SIPCall &call, const std::string &zidFilename
 {
 #endif
     initializeZid();
-    DEBUG("Setting new RTP session with destination %s:%d",
+    SFL_DBG("Setting new RTP session with destination %s:%d",
           localIP.c_str(), call_.getLocalAudioPort());
 }
 
@@ -98,7 +98,7 @@ void AudioZrtpSession::initializeZid()
     }
 #endif
 
-    DEBUG("Initialization from ZID file failed. Trying to remove...");
+    SFL_DBG("Initialization from ZID file failed. Trying to remove...");
 
     if (remove(zidCompleteFilename.c_str()) != 0)
         throw ZrtpZidException("zid file deletion failed");
diff --git a/daemon/src/audio/audiortp/dtmf_event.cpp b/daemon/src/audio/audiortp/dtmf_event.cpp
index bda9cb8d28a89a63840b0bf376fcb7a37ae32c21..f6b7d120bd2e7426734007ff5473b216938cfdd5 100644
--- a/daemon/src/audio/audiortp/dtmf_event.cpp
+++ b/daemon/src/audio/audiortp/dtmf_event.cpp
@@ -68,7 +68,7 @@ DTMFEvent::DTMFEvent(char digit) : payload(), newevent(true), length(1000)
             break;
 
         default:
-            ERROR("Unexpected DTMF %c", digit);
+            SFL_ERR("Unexpected DTMF %c", digit);
     }
 
     payload.event = digit;
diff --git a/daemon/src/audio/audiortp/zrtp_session_callback.cpp b/daemon/src/audio/audiortp/zrtp_session_callback.cpp
index 9acd1f015f26557671fc444adec338f10fb72fea..5ad948f3f016fc1a795fe4fd3701d22710a29782 100644
--- a/daemon/src/audio/audiortp/zrtp_session_callback.cpp
+++ b/daemon/src/audio/audiortp/zrtp_session_callback.cpp
@@ -103,28 +103,28 @@ ZrtpSessionCallback::ZrtpSessionCallback(SIPCall &call) : call_(call)
 void
 ZrtpSessionCallback::secureOn(std::string cipher)
 {
-    DEBUG("Secure mode is on with cipher %s", cipher.c_str());
+    SFL_DBG("Secure mode is on with cipher %s", cipher.c_str());
     Manager::instance().getClient()->getCallManager()->secureZrtpOn(call_.getCallId(), cipher);
 }
 
 void
 ZrtpSessionCallback::secureOff()
 {
-    DEBUG("Secure mode is off");
+    SFL_DBG("Secure mode is off");
     Manager::instance().getClient()->getCallManager()->secureZrtpOff(call_.getCallId());
 }
 
 void
 ZrtpSessionCallback::showSAS(std::string sas, bool verified)
 {
-    DEBUG("SAS is: %s", sas.c_str());
+    SFL_DBG("SAS is: %s", sas.c_str());
     Manager::instance().getClient()->getCallManager()->showSAS(call_.getCallId(), sas, verified);
 }
 
 void
 ZrtpSessionCallback::zrtpNotSuppOther()
 {
-    DEBUG("Callee does not support ZRTP");
+    SFL_DBG("Callee does not support ZRTP");
     Manager::instance().getClient()->getCallManager()->zrtpNotSuppOther(call_.getCallId());
 }
 
@@ -133,9 +133,9 @@ ZrtpSessionCallback::showMessage(GnuZrtpCodes::MessageSeverity sev, int32_t subC
 {
     if (sev == ZrtpError) {
         if (subCode < 0) {  // received an error packet from peer
-            DEBUG("Received an error packet from peer:");
+            SFL_DBG("Received an error packet from peer:");
         } else
-            DEBUG("Sent error packet to peer:");
+            SFL_DBG("Sent error packet to peer:");
     }
 }
 
@@ -145,21 +145,21 @@ ZrtpSessionCallback::zrtpNegotiationFailed(MessageSeverity severity, int subCode
     if (severity == ZrtpError) {
         if (subCode < 0) {  // received an error packet from peer
             subCode *= -1;
-            DEBUG("Received error packet: ");
+            SFL_DBG("Received error packet: ");
         } else
-            DEBUG("Sent error packet: ");
+            SFL_DBG("Sent error packet: ");
 
         std::map<int32, std::string>::const_iterator iter = zrtpMap_.find(subCode);
 
         if (iter != zrtpMap_.end()) {
-            DEBUG("%s", iter->second.c_str());
+            SFL_DBG("%s", iter->second.c_str());
             Manager::instance().getClient()->getCallManager()->zrtpNegotiationFailed(call_.getCallId(), iter->second, "ZRTP");
         }
     } else {
         std::map<int32, std::string>::const_iterator iter = severeMap_.find(subCode);
 
         if (iter != severeMap_.end()) {
-            DEBUG("%s", iter->second.c_str());
+            SFL_DBG("%s", iter->second.c_str());
             Manager::instance().getClient()->getCallManager()->zrtpNegotiationFailed(call_.getCallId(), iter->second, "severe");
         }
     }
@@ -168,7 +168,7 @@ ZrtpSessionCallback::zrtpNegotiationFailed(MessageSeverity severity, int subCode
 void
 ZrtpSessionCallback::confirmGoClear()
 {
-    DEBUG("Received go clear message. Until confirmation, ZRTP won't send any data");
+    SFL_DBG("Received go clear message. Until confirmation, ZRTP won't send any data");
     Manager::instance().getClient()->getCallManager()->zrtpNotSuppOther(call_.getCallId());
 }
 
diff --git a/daemon/src/audio/codecs/audiocodecfactory.cpp b/daemon/src/audio/codecs/audiocodecfactory.cpp
index 6d1087530009a9f2bb74b283da434bed8ed339b0..113a971404482bd7a50868a99cd73c71c4f6ec47 100644
--- a/daemon/src/audio/codecs/audiocodecfactory.cpp
+++ b/daemon/src/audio/codecs/audiocodecfactory.cpp
@@ -55,11 +55,11 @@ AudioCodecFactory::AudioCodecFactory()
     std::vector<sfl::AudioCodec*> codecDynamicList(scanCodecDirectory());
 
     if (codecDynamicList.empty())
-        ERROR("No codecs available");
+        SFL_ERR("No codecs available");
     else {
         for (const auto &codec: codecDynamicList) {
             codecsMap_[(int) codec->getPayloadType()] = codec;
-            DEBUG("Loaded codec %s" , codec->getMimeSubtype().c_str());
+            SFL_DBG("Loaded codec %s" , codec->getMimeSubtype().c_str());
         }
     }
 }
@@ -98,8 +98,10 @@ AudioCodecFactory::getCodec(int payload) const
     auto iter = codecsMap_.find(payload);
     if (iter != codecsMap_.end())
         return iter->second;
-    ERROR("Cannot find codec %i", payload);
-    return nullptr;
+    else {
+        SFL_ERR("Cannot find codec %i", payload);
+        return nullptr;
+    }
 }
 
 sfl::AudioCodec*
@@ -113,14 +115,14 @@ AudioCodecFactory::getCodec(const std::string &name) const
             os << "/" << channels;
 
         const std::string match(iter.second->getMimeSubtype() + os.str());
-        DEBUG("Trying %s", match.c_str());
+        SFL_DBG("Trying %s", match.c_str());
         if (name.find(match) != std::string::npos) {
-            DEBUG("Found match");
+            SFL_DBG("Found match");
             return iter.second;
         }
     }
 
-    ERROR("Cannot find codec %s", name.c_str());
+    SFL_ERR("Cannot find codec %s", name.c_str());
     return nullptr;
 }
 
@@ -197,7 +199,7 @@ AudioCodecFactory::scanCodecDirectory()
     }
 
     for (const auto& dirStr : dirToScan) {
-        DEBUG("Scanning %s to find audio codecs....",  dirStr.c_str());
+        SFL_DBG("Scanning %s to find audio codecs....",  dirStr.c_str());
 
         DIR *dir = opendir(dirStr.c_str());
         if (!dir)
@@ -234,14 +236,14 @@ AudioCodecFactory::loadCodec(const std::string &path)
 
     void* codecHandle = dlopen(path.c_str(), RTLD_NOW);
     if (!codecHandle) {
-        ERROR("%s", dlerror());
+        SFL_ERR("%s", dlerror());
         return nullptr;
     }
 
     create_t* createCodec = (create_t*) dlsym(codecHandle, AUDIO_CODEC_ENTRY_SYMBOL);
     const char *error = dlerror();
     if (error) {
-        ERROR("%s", error);
+        SFL_ERR("%s", error);
         dlclose(codecHandle);
         return nullptr;
     }
@@ -256,7 +258,7 @@ AudioCodecFactory::loadCodec(const std::string &path)
 
         return a;
     } catch (const std::runtime_error &e) {
-        ERROR("%s", e.what());
+        SFL_ERR("%s", e.what());
         dlclose(codecHandle);
         return nullptr;
     }
@@ -276,7 +278,7 @@ AudioCodecFactory::unloadCodec(AudioCodecHandlePointer &ptr)
     const char *error = dlerror();
 
     if (error) {
-        ERROR("%s", error);
+        SFL_ERR("%s", error);
         return;
     }
 
@@ -295,7 +297,7 @@ AudioCodecFactory::instantiateCodec(int payload) const
             try {
                 return codec.first->clone();
             } catch (const std::runtime_error &e) {
-                ERROR("%s", e.what());
+                SFL_ERR("%s", e.what());
                 return nullptr;
             }
         }
diff --git a/daemon/src/audio/codecs/gsmcodec.cpp b/daemon/src/audio/codecs/gsmcodec.cpp
index ae639409f75473daa984ee9047f0486cf264c4a0..000bd71451911c149352db6f6c8f1e2cbd6c986f 100644
--- a/daemon/src/audio/codecs/gsmcodec.cpp
+++ b/daemon/src/audio/codecs/gsmcodec.cpp
@@ -54,10 +54,10 @@ class Gsm : public sfl::AudioCodec {
             hasDynamicPayload_ = false;
 
             if (!(decode_gsmhandle_ = gsm_create()))
-                throw std::runtime_error("ERROR: decode_gsm_create\n");
+                throw std::runtime_error("SFL_ERR: decode_gsm_create\n");
 
             if (!(encode_gsmhandle_ = gsm_create()))
-                throw std::runtime_error("ERROR: encode_gsm_create\n");
+                throw std::runtime_error("SFL_ERR: encode_gsm_create\n");
         }
 
         ~Gsm() {
@@ -74,7 +74,7 @@ private:
         int decode(SFLAudioSample *pcm, unsigned char *data, size_t)
         {
             if (gsm_decode(decode_gsmhandle_, (gsm_byte*) data, (gsm_signal*) pcm) < 0)
-                throw std::runtime_error("ERROR: gsm_decode\n");
+                throw std::runtime_error("SFL_ERR: gsm_decode\n");
 
             return frameSize_;
         }
diff --git a/daemon/src/audio/dsp.cpp b/daemon/src/audio/dsp.cpp
index 2c83c6a93b77cd24e50066142eddf28e8e8be780..eaee672238283522f1ae1efa5f20d49b72325274 100644
--- a/daemon/src/audio/dsp.cpp
+++ b/daemon/src/audio/dsp.cpp
@@ -88,7 +88,7 @@ void DSP::disableDenoise()
 void DSP::process(AudioBuffer& buff, int samples)
 {
     if (samples != smplPerFrame_) {
-        WARN("Unexpected amount of samples");
+        SFL_WARN("Unexpected amount of samples");
         return;
     }
 
diff --git a/daemon/src/audio/jack/jacklayer.cpp b/daemon/src/audio/jack/jacklayer.cpp
index 58a509d29ad3bf0bc8032ec0fe3150b177c84ca6..21ad5ed160e94b0f81fa3cc82aeafc45732215a4 100644
--- a/daemon/src/audio/jack/jacklayer.cpp
+++ b/daemon/src/audio/jack/jacklayer.cpp
@@ -61,12 +61,12 @@ void connectPorts(jack_client_t *client, int portType, const std::vector<jack_po
         const char *port = jack_port_name(ports[i]);
         if (portType & JackPortIsInput) {
             if (jack_connect(client, port, physical_ports[i])) {
-                ERROR("Can't connect %s to %s", port, physical_ports[i]);
+                SFL_ERR("Can't connect %s to %s", port, physical_ports[i]);
                 break;
             }
         } else {
             if (jack_connect(client, physical_ports[i], port)) {
-                ERROR("Can't connect port %s to %s", physical_ports[i], port);
+                SFL_ERR("Can't connect port %s to %s", physical_ports[i], port);
                 break;
             }
         }
@@ -102,7 +102,7 @@ void JackLayer::fillWithVoice(AudioBuffer &buffer, size_t samplesAvail)
     buffer.applyGain(isPlaybackMuted_ ? 0.0 : playbackGain_);
 
     if (audioFormat_.sample_rate != (unsigned) mainBuffer.getInternalSamplingRate()) {
-        DEBUG("fillWithVoice sample_rate != mainBuffer.getInternalSamplingRate() \n");
+        SFL_DBG("fillWithVoice sample_rate != mainBuffer.getInternalSamplingRate() \n");
         AudioBuffer out(buffer, false);
         out.setSampleRate(audioFormat_.sample_rate);
         resampler_->resample(buffer, out);
@@ -177,7 +177,7 @@ convertToFloat(const std::vector<SFLAudioSample> &src, std::vector<float> &dest)
 {
     static const float INV_SHORT_MAX = 1 / (float) SHRT_MAX;
     if (dest.size() != src.size()) {
-        ERROR("MISMATCH");
+        SFL_ERR("MISMATCH");
         return;
     }
     for (size_t i = 0; i < dest.size(); ++i)
@@ -188,7 +188,7 @@ static void
 convertFromFloat(std::vector<float> &src, std::vector<SFLAudioSample> &dest)
 {
     if (dest.size() != src.size()) {
-        ERROR("MISMATCH");
+        SFL_ERR("MISMATCH");
         return;
     }
     for (size_t i = 0; i < dest.size(); ++i)
@@ -209,7 +209,7 @@ JackLayer::write(AudioBuffer &buffer, std::vector<float> &floatBuffer)
         const size_t written_bytes = jack_ringbuffer_write(out_ringbuffers_[i],
                 (const char *) floatBuffer.data(), write_bytes);
         if (written_bytes < write_bytes)
-            WARN("Dropped %zu bytes for channel %u", write_bytes - written_bytes, i);
+            SFL_WARN("Dropped %zu bytes for channel %u", write_bytes - written_bytes, i);
     }
 }
 
@@ -232,7 +232,7 @@ JackLayer::read(AudioBuffer &buffer)
         const size_t read_bytes = jack_ringbuffer_read(in_ringbuffers_[i],
                 (char *) captureFloatBuffer_.data(), expected_bytes);
         if (read_bytes < expected_bytes) {
-            WARN("Dropped %zu bytes", expected_bytes - read_bytes);
+            SFL_WARN("Dropped %zu bytes", expected_bytes - read_bytes);
             break;
         }
 
@@ -350,7 +350,7 @@ JackLayer::JackLayer(const AudioPreference &p) :
     const auto playRate = jack_get_sample_rate(playbackClient_);
     const auto captureRate = jack_get_sample_rate(captureClient_);
     if (playRate != captureRate)
-        ERROR("Mismatch between capture rate %u and playback rate %u", playRate, captureRate);
+        SFL_ERR("Mismatch between capture rate %u and playback rate %u", playRate, captureRate);
 
     hardwareBufferSize_ = jack_get_buffer_size(playbackClient_);
 
@@ -376,9 +376,9 @@ JackLayer::~JackLayer()
         jack_port_unregister(captureClient_, p);
 
     if (jack_client_close(playbackClient_))
-        ERROR("JACK client could not close");
+        SFL_ERR("JACK client could not close");
     if (jack_client_close(captureClient_))
-        ERROR("JACK client could not close");
+        SFL_ERR("JACK client could not close");
 
     for (auto r : out_ringbuffers_)
         jack_ringbuffer_free(r);
@@ -433,7 +433,7 @@ JackLayer::process_capture(jack_nframes_t frames, void *arg)
         // fill the rest with silence
         if (bytes_to_rb < bytes_to_read) {
             // TODO: set some flag for underrun?
-            WARN("Dropped %lu bytes", bytes_to_read - bytes_to_rb);
+            SFL_WARN("Dropped %lu bytes", bytes_to_read - bytes_to_rb);
         }
     }
 
@@ -490,7 +490,7 @@ JackLayer::startStream()
     ringbuffer_thread_ = std::thread(&JackLayer::ringbuffer_worker, this);
 
     if (jack_activate(playbackClient_) or jack_activate(captureClient_)) {
-        ERROR("Could not activate JACK client");
+        SFL_ERR("Could not activate JACK client");
         workerAlive_ = false;
         ringbuffer_thread_.join();
         isStarted_ = false;
@@ -506,7 +506,7 @@ JackLayer::startStream()
 void
 JackLayer::onShutdown(void * /* data */)
 {
-    WARN("JACK server shutdown");
+    SFL_WARN("JACK server shutdown");
     // FIXME: handle this safely
 }
 
@@ -523,7 +523,7 @@ JackLayer::stopStream()
     }
 
     if (jack_deactivate(playbackClient_) or jack_deactivate(captureClient_)) {
-        ERROR("JACK client could not deactivate");
+        SFL_ERR("JACK client could not deactivate");
     }
 
     isStarted_ = false;
diff --git a/daemon/src/audio/opensl/opensllayer.cpp b/daemon/src/audio/opensl/opensllayer.cpp
index 22d23d6fce5ed86c9251a0bb97ee047d45c525cd..e9c29429d17fdf9c6bb2d0d246b3fa6fe91d8f97 100644
--- a/daemon/src/audio/opensl/opensllayer.cpp
+++ b/daemon/src/audio/opensl/opensllayer.cpp
@@ -113,7 +113,7 @@ OpenSLLayer::startStream()
     if (isStarted_)
         return;
 
-    DEBUG("Start OpenSL audio layer");
+    SFL_DBG("Start OpenSL audio layer");
 
     std::vector<int32_t> hw_infos = Manager::instance().getClient()->getConfigurationManager()->getHardwareAudioFormat();
     hardwareFormat_ = AudioFormat(hw_infos[0], 1);  // Mono on Android
@@ -141,7 +141,7 @@ OpenSLLayer::stopStream()
     if (not isStarted_)
         return;
 
-    DEBUG("Stop OpenSL audio layer");
+    SFL_DBG("Stop OpenSL audio layer");
 
     stopAudioPlayback();
     stopAudioCapture();
@@ -157,30 +157,30 @@ OpenSLLayer::initAudioEngine() const
 {
     SLresult result;
 
-    DEBUG("Create Audio Engine\n");
+    SFL_DBG("Create Audio Engine\n");
     result = slCreateEngine((const SLObjectItf_ * const **)&engineObject_, 0, nullptr, 0, nullptr, nullptr);
     assert(SL_RESULT_SUCCESS == result);
 
-    DEBUG("Realize Audio Engine\n");
+    SFL_DBG("Realize Audio Engine\n");
     result = (*engineObject_)->Realize(engineObject_, SL_BOOLEAN_FALSE);
     assert(SL_RESULT_SUCCESS == result);
 
-    DEBUG("Create Audio Engine Interface\n");
+    SFL_DBG("Create Audio Engine Interface\n");
     result = (*engineObject_)->GetInterface(engineObject_, SL_IID_ENGINE,
                                             (void *)&engineInterface_);
     assert(SL_RESULT_SUCCESS == result);
 
-    DEBUG("Create Output Mixer\n");
+    SFL_DBG("Create Output Mixer\n");
     result = (*engineInterface_)->CreateOutputMix(engineInterface_,
                                                   (const SLObjectItf_ * const **)&outputMixer_,
                                                   0, nullptr, nullptr);
     assert(SL_RESULT_SUCCESS == result);
 
-    DEBUG("Realize Output Mixer\n");
+    SFL_DBG("Realize Output Mixer\n");
     result = (*outputMixer_)->Realize(outputMixer_, SL_BOOLEAN_FALSE);
     assert(SL_RESULT_SUCCESS == result);
 
-    DEBUG("Audio Engine Initialization Done\n");
+    SFL_DBG("Audio Engine Initialization Done\n");
 }
 
 void
@@ -188,7 +188,7 @@ OpenSLLayer::shutdownAudioEngine()
 {
 
     // destroy buffer queue audio player object, and invalidate all associated interfaces
-    DEBUG("Shutdown audio player\n");
+    SFL_DBG("Shutdown audio player\n");
 
     if (playerObject_ != nullptr) {
         (*playerObject_)->Destroy(playerObject_);
@@ -198,7 +198,7 @@ OpenSLLayer::shutdownAudioEngine()
     }
 
     // destroy output mix object, and invalidate all associated interfaces
-    DEBUG("Shutdown audio mixer\n");
+    SFL_DBG("Shutdown audio mixer\n");
 
     if (outputMixer_ != nullptr) {
         (*outputMixer_)->Destroy(outputMixer_);
@@ -213,7 +213,7 @@ OpenSLLayer::shutdownAudioEngine()
     }
 
     // destroy engine object, and invalidate all associated interfaces
-    DEBUG("Shutdown audio engine\n");
+    SFL_DBG("Shutdown audio engine\n");
     if (engineObject_ != nullptr) {
         (*engineObject_)->Destroy(engineObject_);
         engineObject_ = nullptr;
@@ -231,13 +231,13 @@ OpenSLLayer::initAudioPlayback() const
     SLresult result;
 
     // Initialize the location of the buffer queue
-    DEBUG("Create playback queue\n");
+    SFL_DBG("Create playback queue\n");
     SLDataLocator_AndroidSimpleBufferQueue bufferLocation = {SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE,
                                                             NB_BUFFER_PLAYBACK_QUEUE
                                                             };
 
     // Initnialize the audio format for this queue
-    DEBUG("Setting audio format\n");
+    SFL_DBG("Setting audio format\n");
     SLDataFormat_PCM audioFormat = {SL_DATAFORMAT_PCM,
                                     1,
                                     audioFormat_.sample_rate * 1000,
@@ -248,16 +248,16 @@ OpenSLLayer::initAudioPlayback() const
                                    };
 
     // Create the audio source
-    DEBUG("Set Audio Sources\n");
+    SFL_DBG("Set Audio Sources\n");
     SLDataSource audioSource = {&bufferLocation, &audioFormat};
 
-    DEBUG("Get Output Mixer interface\n");
+    SFL_DBG("Get Output Mixer interface\n");
     result = (*outputMixer_)->GetInterface(outputMixer_, SL_IID_OUTPUTMIX,
                                            (void *)&outputMixInterface_);
     CheckErr(result);
 
     // Cofiguration fo the audio sink as an output mixer
-    DEBUG("Set output mixer location\n");
+    SFL_DBG("Set output mixer location\n");
     SLDataLocator_OutputMix mixerLocation = {SL_DATALOCATOR_OUTPUTMIX, outputMixer_};
     SLDataSink audioSink = {&mixerLocation, nullptr};
 
@@ -270,7 +270,7 @@ OpenSLLayer::initAudioPlayback() const
     const unsigned nbInterface = SFL_ARRAYSIZE(ids);
 
     // create audio player
-    DEBUG("Create audio player\n");
+    SFL_DBG("Create audio player\n");
     result = (*engineInterface_)->CreateAudioPlayer(engineInterface_,
                                                     (const SLObjectItf_ * const **)&playerObject_,
                                                     &audioSource,
@@ -293,34 +293,34 @@ OpenSLLayer::initAudioPlayback() const
                      &streamType, sizeof(SLint32));
     }
 
-    DEBUG("Realize audio player\n");
+    SFL_DBG("Realize audio player\n");
     result = (*playerObject_)->Realize(playerObject_, SL_BOOLEAN_FALSE);
     assert(SL_RESULT_SUCCESS == result);
 
     if (result != SL_RESULT_SUCCESS) {
-        ERROR("Unable to set android player configuration");
+        SFL_ERR("Unable to set android player configuration");
     }
 
     // create audio interface
-    DEBUG("Create audio player interface\n");
+    SFL_DBG("Create audio player interface\n");
     result = (*playerObject_)->GetInterface(playerObject_, SL_IID_PLAY,
                                             (void *)&playerInterface_);
     assert(SL_RESULT_SUCCESS == result);
 
     // create the buffer queue interface
-    DEBUG("Create buffer queue interface\n");
+    SFL_DBG("Create buffer queue interface\n");
     result = (*playerObject_)->GetInterface(playerObject_, SL_IID_BUFFERQUEUE,
                                             (void *)&playbackBufferQueue_);
     assert(SL_RESULT_SUCCESS == result);
 
     // register the buffer queue on the buffer object
-    DEBUG("Register audio callback\n");
+    SFL_DBG("Register audio callback\n");
     result = (*playbackBufferQueue_)->RegisterCallback(playbackBufferQueue_,
                                                        audioPlaybackCallback,
                                                        (void *)this);
     assert(SL_RESULT_SUCCESS == result);
 
-    DEBUG("Audio Playback Initialization Done\n");
+    SFL_DBG("Audio Playback Initialization Done\n");
 }
 
 void
@@ -329,7 +329,7 @@ OpenSLLayer::initAudioCapture() const
     SLresult result;
 
     // configure audio source
-    DEBUG("Configure audio source\n");
+    SFL_DBG("Configure audio source\n");
     SLDataLocator_IODevice deviceLocator = {SL_DATALOCATOR_IODEVICE,
                                             SL_IODEVICE_AUDIOINPUT,
                                             SL_DEFAULTDEVICEID_AUDIOINPUT,
@@ -341,14 +341,14 @@ OpenSLLayer::initAudioCapture() const
                                };
 
     // configure audio sink
-    DEBUG("Configure audio sink\n");
+    SFL_DBG("Configure audio sink\n");
 
     SLDataLocator_AndroidSimpleBufferQueue bufferLocator = {SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE,
                                            NB_BUFFER_CAPTURE_QUEUE
                                                            };
 
-    DEBUG("Capture-> Sampling Rate: %d", audioFormat_.sample_rate);
-    DEBUG("Capture-> getInternalSamplingRate: %d", Manager::instance().getRingBufferPool().getInternalSamplingRate());
+    SFL_DBG("Capture-> Sampling Rate: %d", audioFormat_.sample_rate);
+    SFL_DBG("Capture-> getInternalSamplingRate: %d", Manager::instance().getRingBufferPool().getInternalSamplingRate());
     SLDataFormat_PCM audioFormat = {SL_DATAFORMAT_PCM, 1,
                                     audioFormat_.sample_rate * 1000,
                                     SL_PCMSAMPLEFORMAT_FIXED_16,
@@ -363,7 +363,7 @@ OpenSLLayer::initAudioCapture() const
 
     // create audio recorder
     // (requires the RECORD_AUDIO permission)
-    DEBUG("Create audio recorder\n");
+    SFL_DBG("Create audio recorder\n");
     const SLInterfaceID id[2] = {SL_IID_ANDROIDSIMPLEBUFFERQUEUE,
                                 SL_IID_ANDROIDCONFIGURATION};
     const SLboolean req[2] ={SL_BOOLEAN_TRUE,
@@ -379,7 +379,7 @@ OpenSLLayer::initAudioCapture() const
     }
 
     if (SL_RESULT_SUCCESS != result) {
-        DEBUG("Error: could not create audio recorder");
+        SFL_DBG("Error: could not create audio recorder");
         return;
     }
 
@@ -395,40 +395,40 @@ OpenSLLayer::initAudioCapture() const
     }
 
     if (result != SL_RESULT_SUCCESS) {
-        DEBUG("Warning: Unable to set android recorder configuration");
+        SFL_DBG("Warning: Unable to set android recorder configuration");
         return;
     }
 
     // realize the audio recorder
-    DEBUG("Realize the audio recorder\n");
+    SFL_DBG("Realize the audio recorder\n");
     result = (*recorderObject_)->Realize(recorderObject_, SL_BOOLEAN_FALSE);
 
     if (SL_RESULT_SUCCESS != result) {
-        DEBUG("Error: could not realize audio recorder");
+        SFL_DBG("Error: could not realize audio recorder");
         return;
     }
 
     // get the record interface
-    DEBUG("Create the record interface\n");
+    SFL_DBG("Create the record interface\n");
     result = (*recorderObject_)->GetInterface(recorderObject_,
                                               SL_IID_RECORD,
                                               (void *)&recorderInterface_);
     assert(SL_RESULT_SUCCESS == result);
 
     // get the buffer queue interface
-    DEBUG("Create the buffer queue interface\n");
+    SFL_DBG("Create the buffer queue interface\n");
     result = (*recorderObject_)->GetInterface(recorderObject_, SL_IID_ANDROIDSIMPLEBUFFERQUEUE,
              (void *)&recorderBufferQueue_);
     assert(SL_RESULT_SUCCESS == result);
 
     // register callback on the buffer queue
-    DEBUG("Register the audio capture callback\n");
+    SFL_DBG("Register the audio capture callback\n");
     result = (*recorderBufferQueue_)->RegisterCallback(recorderBufferQueue_,
                                                        audioCaptureCallback,
                                                        (void *)this);
     assert(SL_RESULT_SUCCESS == result);
 
-    DEBUG("Audio capture initialized\n");
+    SFL_DBG("Audio capture initialized\n");
 }
 
 
@@ -437,7 +437,7 @@ OpenSLLayer::startAudioPlayback()
 {
     assert(nullptr != playbackBufferQueue_);
 
-    DEBUG("Start audio playback\n");
+    SFL_DBG("Start audio playback\n");
 
     SLresult result;
 
@@ -450,14 +450,14 @@ OpenSLLayer::startAudioPlayback()
         result = (*playbackBufferQueue_)->Enqueue(playbackBufferQueue_, buffer.getChannel(0)->data(), buffer.frames());
 
         if (SL_RESULT_SUCCESS != result) {
-            DEBUG("Error could not enqueue initial buffers\n");
+            SFL_DBG("Error could not enqueue initial buffers\n");
         }
     }
 
     result = (*playerInterface_)->SetPlayState(playerInterface_, SL_PLAYSTATE_PLAYING);
     assert(SL_RESULT_SUCCESS == result);
 
-    DEBUG("Audio playback started\n");
+    SFL_DBG("Audio playback started\n");
 }
 
 void
@@ -465,7 +465,7 @@ OpenSLLayer::startAudioCapture()
 {
     assert(nullptr != playbackBufferQueue_);
 
-    DEBUG("Start audio capture\n");
+    SFL_DBG("Start audio capture\n");
 
     SLresult result;
 
@@ -476,11 +476,11 @@ OpenSLLayer::startAudioCapture()
         assert(SL_RESULT_SUCCESS == result);
     }
 
-    DEBUG("Clearing recorderBufferQueue\n");
+    SFL_DBG("Clearing recorderBufferQueue\n");
     result = (*recorderBufferQueue_)->Clear(recorderBufferQueue_);
     assert(SL_RESULT_SUCCESS == result);
 
-    DEBUG("getting next record buffer\n");
+    SFL_DBG("getting next record buffer\n");
     // enqueue an empty buffer to be filled by the recorder
     // (for streaming recording, we enqueue at least 2 empty buffers to start things off)
     AudioBuffer &buffer = getNextRecordBuffer();
@@ -488,13 +488,13 @@ OpenSLLayer::startAudioCapture()
 
     buffer.reset();
 
-    DEBUG("Enqueue record buffer\n");
+    SFL_DBG("Enqueue record buffer\n");
     result = (*recorderBufferQueue_)->Enqueue(recorderBufferQueue_, buffer.getChannel(0)->data(), buffer.frames());
 
     // the most likely other result is SL_RESULT_BUFFER_INSUFFICIENT,
     // which for this code example would indicate a programming error
     if (SL_RESULT_SUCCESS != result) {
-        DEBUG("Error could not enqueue buffers in audio capture\n");
+        SFL_DBG("Error could not enqueue buffers in audio capture\n");
         return;
     }
 
@@ -502,13 +502,13 @@ OpenSLLayer::startAudioCapture()
     result = (*recorderInterface_)->SetRecordState(recorderInterface_, SL_RECORDSTATE_RECORDING);
     assert(SL_RESULT_SUCCESS == result);
 
-    DEBUG("Audio capture started\n");
+    SFL_DBG("Audio capture started\n");
 }
 
 void
 OpenSLLayer::stopAudioPlayback()
 {
-    DEBUG("Stop audio playback\n");
+    SFL_DBG("Stop audio playback\n");
 
     if (playerInterface_ != nullptr) {
         SLresult result;
@@ -516,13 +516,13 @@ OpenSLLayer::stopAudioPlayback()
         assert(SL_RESULT_SUCCESS == result);
     }
 
-    DEBUG("Audio playback stopped\n");
+    SFL_DBG("Audio playback stopped\n");
 }
 
 void
 OpenSLLayer::stopAudioCapture()
 {
-    DEBUG("Stop audio capture\n");
+    SFL_DBG("Stop audio capture\n");
 
     if (recorderInterface_ != nullptr) {
         SLresult result;
@@ -530,7 +530,7 @@ OpenSLLayer::stopAudioCapture()
         assert(SL_RESULT_SUCCESS == result);
     }
 
-    DEBUG("Audio capture stopped\n");
+    SFL_DBG("Audio capture stopped\n");
 
 }
 
@@ -559,12 +559,12 @@ OpenSLLayer::getCaptureDeviceList() const
 
 
     // Get the Audio IO DEVICE CAPABILITIES interface, implicit
-    DEBUG("Get the Audio IO DEVICE CAPABILITIES interface, implicit");
+    SFL_DBG("Get the Audio IO DEVICE CAPABILITIES interface, implicit");
 
     res = (*engineObject_)->GetInterface(engineObject_, SL_IID_AUDIOIODEVICECAPABILITIES, (void*)&AudioIODeviceCapabilitiesItf);
     CheckErr(res);
 
-    DEBUG("Get the Audio IO DEVICE CAPABILITIES interface, implicit");
+    SFL_DBG("Get the Audio IO DEVICE CAPABILITIES interface, implicit");
     numInputs = MAX_NUMBER_INPUT_DEVICES;
 
     res = (*AudioIODeviceCapabilitiesItf)->GetAvailableAudioInputs(AudioIODeviceCapabilitiesItf, &numInputs, InputDeviceIDs);
@@ -581,14 +581,14 @@ OpenSLLayer::getCaptureDeviceList() const
         if (AudioInputDescriptor.deviceConnection == SL_DEVCONNECTION_ATTACHED_WIRED and
             AudioInputDescriptor.deviceScope == SL_DEVSCOPE_USER and
             AudioInputDescriptor.deviceLocation == SL_DEVLOCATION_HEADSET) {
-            DEBUG("SL_DEVCONNECTION_ATTACHED_WIRED : mic_deviceID: %d", InputDeviceIDs[i] );
+            SFL_DBG("SL_DEVCONNECTION_ATTACHED_WIRED : mic_deviceID: %d", InputDeviceIDs[i] );
             mic_deviceID = InputDeviceIDs[i];
             mic_available = SL_BOOLEAN_TRUE;
             break;
         } else if (AudioInputDescriptor.deviceConnection == SL_DEVCONNECTION_INTEGRATED and
                    AudioInputDescriptor.deviceScope == SL_DEVSCOPE_USER and
                    AudioInputDescriptor.deviceLocation == SL_DEVLOCATION_HANDSET) {
-            DEBUG("SL_DEVCONNECTION_INTEGRATED : mic_deviceID: %d", InputDeviceIDs[i] );
+            SFL_DBG("SL_DEVCONNECTION_INTEGRATED : mic_deviceID: %d", InputDeviceIDs[i] );
             mic_deviceID = InputDeviceIDs[i];
             mic_available = SL_BOOLEAN_TRUE;
             break;
@@ -597,7 +597,7 @@ OpenSLLayer::getCaptureDeviceList() const
 
     if (!mic_available) {
         // Appropriate error message here
-        ERROR("No mic available quitting");
+        SFL_ERR("No mic available quitting");
         exit(1);
     }
 
@@ -631,7 +631,7 @@ OpenSLLayer::audioPlaybackCallback(SLAndroidSimpleBufferQueueItf queue, void *co
     static_cast<OpenSLLayer*>(context)->playback(queue);
     //auto end = std::chrono::high_resolution_clock::now();
     //auto elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(end - start);
-    //DEBUG("Took %d us\n", elapsed/1000);
+    //SFL_DBG("Took %d us\n", elapsed/1000);
 }
 
 void
@@ -660,11 +660,11 @@ OpenSLLayer::playback(SLAndroidSimpleBufferQueueItf queue)
     if (bufferIsFilled_) {
         SLresult result = (*queue)->Enqueue(queue, buffer.getChannel(0)->data(), buffer.frames()*sizeof(SFLAudioSample));
         if (SL_RESULT_SUCCESS != result) {
-            DEBUG("Error could not enqueue buffers in playback callback\n");
+            SFL_DBG("Error could not enqueue buffers in playback callback\n");
         }
         incrementPlaybackIndex();
     } else {
-        DEBUG("Error buffer not filled in audio playback\n");
+        SFL_DBG("Error buffer not filled in audio playback\n");
     }
 }
 
@@ -779,7 +779,7 @@ size_t OpenSLLayer::audioPlaybackFillWithVoice(AudioBuffer &buffer)
     buffer.resize(got);
     buffer.applyGain(isPlaybackMuted_ ? 0.0 : playbackGain_);
     if (audioFormat_.sample_rate != mainBuffer.getInternalSamplingRate()) {
-        DEBUG("OpenSLLayer::audioPlaybackFillWithVoice sample_rate != mainBuffer.getInternalSamplingRate() \n");
+        SFL_DBG("OpenSLLayer::audioPlaybackFillWithVoice sample_rate != mainBuffer.getInternalSamplingRate() \n");
         AudioBuffer out(buffer, false);
         out.setSampleRate(audioFormat_.sample_rate);
         resampler_->resample(buffer, out);
@@ -791,14 +791,14 @@ size_t OpenSLLayer::audioPlaybackFillWithVoice(AudioBuffer &buffer)
 void dumpAvailableEngineInterfaces()
 {
     SLresult result;
-    DEBUG("Engine Interfaces\n");
+    SFL_DBG("Engine Interfaces\n");
     SLuint32 numSupportedInterfaces;
     result = slQueryNumSupportedEngineInterfaces(&numSupportedInterfaces);
     assert(SL_RESULT_SUCCESS == result);
     result = slQueryNumSupportedEngineInterfaces(NULL);
     assert(SL_RESULT_PARAMETER_INVALID == result);
 
-    DEBUG("Engine number of supported interfaces %lu\n", numSupportedInterfaces);
+    SFL_DBG("Engine number of supported interfaces %lu\n", numSupportedInterfaces);
     for(SLuint32 i=0; i< numSupportedInterfaces; i++){
         SLInterfaceID  pInterfaceId;
         slQuerySupportedEngineInterfaces(i, &pInterfaceId);
@@ -854,7 +854,7 @@ void dumpAvailableEngineInterfaces()
         else if (pInterfaceId==SL_IID_ANDROIDCONFIGURATION) nm="androidconfiguration";
         else if (pInterfaceId==SL_IID_ANDROIDSIMPLEBUFFERQUEUE) nm="simplebuferqueue";
         //else if (pInterfaceId==//SL_IID_ANDROIDBUFFERQUEUESOURCE) nm="bufferqueuesource";
-        DEBUG("%s,",nm);
+        SFL_DBG("%s,",nm);
     }
 }
 
diff --git a/daemon/src/audio/pulseaudio/audiostream.cpp b/daemon/src/audio/pulseaudio/audiostream.cpp
index 86e3ffca32813a51b03efbac3d1722df8f6c2dcd..491b1d84f5b3b650484e3cc7163d2a61d4bf8ff1 100644
--- a/daemon/src/audio/pulseaudio/audiostream.cpp
+++ b/daemon/src/audio/pulseaudio/audiostream.cpp
@@ -51,7 +51,7 @@ AudioStream::AudioStream(pa_context *c,
         channel_map.channels
     };
 
-    DEBUG("%s: trying to create stream with device %s (%dHz, %d channels)", desc, infos->name.c_str(), samplrate, channel_map.channels);
+    SFL_DBG("%s: trying to create stream with device %s (%dHz, %d channels)", desc, infos->name.c_str(), samplrate, channel_map.channels);
 
     assert(pa_sample_spec_valid(&sample_spec));
     assert(pa_channel_map_valid(&channel_map));
@@ -59,7 +59,7 @@ AudioStream::AudioStream(pa_context *c,
     audiostream_ = pa_stream_new(c, desc, &sample_spec, &channel_map);
 
     if (!audiostream_) {
-        ERROR("%s: pa_stream_new() failed : %s" , desc, pa_strerror(pa_context_errno(c)));
+        SFL_ERR("%s: pa_stream_new() failed : %s" , desc, pa_strerror(pa_context_errno(c)));
         throw std::runtime_error("Could not create stream\n");
     }
 
@@ -115,32 +115,32 @@ AudioStream::stream_state_callback(pa_stream* s, void* /*user_data*/)
 
     switch (pa_stream_get_state(s)) {
         case PA_STREAM_CREATING:
-            DEBUG("Stream is creating...");
+            SFL_DBG("Stream is creating...");
             break;
 
         case PA_STREAM_TERMINATED:
-            DEBUG("Stream is terminating...");
+            SFL_DBG("Stream is terminating...");
             break;
 
         case PA_STREAM_READY:
-            DEBUG("Stream successfully created, connected to %s", pa_stream_get_device_name(s));
+            SFL_DBG("Stream successfully created, connected to %s", pa_stream_get_device_name(s));
 #if 0
-            DEBUG("maxlength %u", pa_stream_get_buffer_attr(s)->maxlength);
-            DEBUG("tlength %u", pa_stream_get_buffer_attr(s)->tlength);
-            DEBUG("prebuf %u", pa_stream_get_buffer_attr(s)->prebuf);
-            DEBUG("minreq %u", pa_stream_get_buffer_attr(s)->minreq);
-            DEBUG("fragsize %u", pa_stream_get_buffer_attr(s)->fragsize);
+            SFL_DBG("maxlength %u", pa_stream_get_buffer_attr(s)->maxlength);
+            SFL_DBG("tlength %u", pa_stream_get_buffer_attr(s)->tlength);
+            SFL_DBG("prebuf %u", pa_stream_get_buffer_attr(s)->prebuf);
+            SFL_DBG("minreq %u", pa_stream_get_buffer_attr(s)->minreq);
+            SFL_DBG("fragsize %u", pa_stream_get_buffer_attr(s)->fragsize);
 #endif
-            DEBUG("samplespec %s", pa_sample_spec_snprint(str, sizeof(str), pa_stream_get_sample_spec(s)));
+            SFL_DBG("samplespec %s", pa_sample_spec_snprint(str, sizeof(str), pa_stream_get_sample_spec(s)));
             break;
 
         case PA_STREAM_UNCONNECTED:
-            DEBUG("Stream unconnected");
+            SFL_DBG("Stream unconnected");
             break;
 
         case PA_STREAM_FAILED:
         default:
-            ERROR("Sink/Source doesn't exists: %s" , pa_strerror(pa_context_errno(pa_stream_get_context(s))));
+            SFL_ERR("Sink/Source doesn't exists: %s" , pa_strerror(pa_context_errno(pa_stream_get_context(s))));
             break;
     }
 }
diff --git a/daemon/src/audio/pulseaudio/pulselayer.cpp b/daemon/src/audio/pulseaudio/pulselayer.cpp
index 366760c6bc4272d6591e32ccdb9efcf6f1b06a5e..04337db9b424037514e494f601d939884e62e0eb 100644
--- a/daemon/src/audio/pulseaudio/pulselayer.cpp
+++ b/daemon/src/audio/pulseaudio/pulselayer.cpp
@@ -72,7 +72,7 @@ ringtone_callback(pa_stream * /*s*/, size_t /*bytes*/, void* userdata)
 static void
 stream_moved_callback(pa_stream *s, void *userdata UNUSED)
 {
-    DEBUG("stream %d to %d", pa_stream_get_index(s), pa_stream_get_device_index(s));
+    SFL_DBG("stream %d to %d", pa_stream_get_index(s), pa_stream_get_device_index(s));
 }
 
 PulseMainLoopLock::PulseMainLoopLock(pa_threaded_mainloop *loop) : loop_(loop), destroyLoop_(false)
@@ -184,11 +184,11 @@ void PulseLayer::context_state_callback(pa_context* c, void *user_data)
         case PA_CONTEXT_CONNECTING:
         case PA_CONTEXT_AUTHORIZING:
         case PA_CONTEXT_SETTING_NAME:
-            DEBUG("Waiting....");
+            SFL_DBG("Waiting....");
             break;
 
         case PA_CONTEXT_READY:
-            DEBUG("Connection to PulseAudio server established");
+            SFL_DBG("Connection to PulseAudio server established");
             pa_threaded_mainloop_signal(pulse->mainloop_, 0);
             pa_context_subscribe(c, mask, nullptr, pulse);
             pa_context_set_subscribe_callback(c, context_changed_callback, pulse);
@@ -202,7 +202,7 @@ void PulseLayer::context_state_callback(pa_context* c, void *user_data)
 
         case PA_CONTEXT_FAILED:
         default:
-            ERROR("%s" , pa_strerror(pa_context_errno(c)));
+            SFL_ERR("%s" , pa_strerror(pa_context_errno(c)));
             pa_threaded_mainloop_signal(pulse->mainloop_, 0);
             break;
     }
@@ -242,7 +242,7 @@ bool PulseLayer::inSinkList(const std::string &deviceName)
 {
     const bool found = std::find_if(sinkList_.begin(), sinkList_.end(), PaDeviceInfos::NameComparator(deviceName)) != sinkList_.end();
 
-    DEBUG("seeking for %s in sinks. %s found", deviceName.c_str(), found ? "" : "NOT");
+    SFL_DBG("seeking for %s in sinks. %s found", deviceName.c_str(), found ? "" : "NOT");
     return found;
 }
 
@@ -250,7 +250,7 @@ bool PulseLayer::inSourceList(const std::string &deviceName)
 {
     const bool found = std::find_if(sourceList_.begin(), sourceList_.end(), PaDeviceInfos::NameComparator(deviceName)) != sourceList_.end();
 
-    DEBUG("seeking for %s in sources. %s found", deviceName.c_str(), found ? "" : "NOT");
+    SFL_DBG("seeking for %s in sources. %s found", deviceName.c_str(), found ? "" : "NOT");
     return found;
 }
 
@@ -285,7 +285,7 @@ int PulseLayer::getAudioDeviceIndex(const std::string& descr, DeviceType type) c
     case DeviceType::CAPTURE:
         return 1 + std::distance(sourceList_.begin(), std::find_if(sourceList_.begin(), sourceList_.end(), PaDeviceInfos::DescriptionComparator(descr)));
     default:
-        ERROR("Unexpected device type");
+        SFL_ERR("Unexpected device type");
         return 0;
     }
 }
@@ -301,7 +301,7 @@ int PulseLayer::getAudioDeviceIndexByName(const std::string& name, DeviceType ty
     case DeviceType::CAPTURE:
         return 1 + std::distance(sourceList_.begin(), std::find_if(sourceList_.begin(), sourceList_.end(), PaDeviceInfos::NameComparator(name)));
     default:
-        ERROR("Unexpected device type");
+        SFL_ERR("Unexpected device type");
         return 0;
     }
 }
@@ -324,7 +324,7 @@ std::string PulseLayer::getAudioDeviceName(int index, DeviceType type) const
         case DeviceType::PLAYBACK:
         case DeviceType::RINGTONE:
             if (index < 0 or static_cast<size_t>(index) >= sinkList_.size()) {
-                ERROR("Index %d out of range", index);
+                SFL_ERR("Index %d out of range", index);
                 return "";
             }
 
@@ -332,14 +332,14 @@ std::string PulseLayer::getAudioDeviceName(int index, DeviceType type) const
 
         case DeviceType::CAPTURE:
             if (index < 0 or static_cast<size_t>(index) >= sourceList_.size()) {
-                ERROR("Index %d out of range", index);
+                SFL_ERR("Index %d out of range", index);
                 return "";
             }
 
             return sourceList_[index].name;
         default:
             // Should never happen
-            ERROR("Unexpected type");
+            SFL_ERR("Unexpected type");
             return "";
     }
 }
@@ -363,7 +363,7 @@ void PulseLayer::createStreams(pa_context* c)
     if (ringtoneDevice.empty())
         ringtoneDevice = defaultSink_;
 
-    DEBUG("playback: %s record: %s ringtone: %s", playbackDevice.c_str(),
+    SFL_DBG("playback: %s record: %s ringtone: %s", playbackDevice.c_str(),
           captureDevice.c_str(), ringtoneDevice.c_str());
 
     // Create playback stream
@@ -371,7 +371,7 @@ void PulseLayer::createStreams(pa_context* c)
 
     if (dev_infos == nullptr) {
         dev_infos = &sinkList_[0];
-        WARN("Prefered playback device %s not found in device list, selecting %s instead.",
+        SFL_WARN("Prefered playback device %s not found in device list, selecting %s instead.",
              playbackDevice.c_str(), dev_infos->name.c_str());
     }
 
@@ -385,7 +385,7 @@ void PulseLayer::createStreams(pa_context* c)
 
     if (dev_infos == nullptr) {
         dev_infos = &sourceList_[0];
-        WARN("Prefered capture device %s not found in device list, selecting %s instead.",
+        SFL_WARN("Prefered capture device %s not found in device list, selecting %s instead.",
              captureDevice.c_str(), dev_infos->name.c_str());
     }
 
@@ -399,7 +399,7 @@ void PulseLayer::createStreams(pa_context* c)
 
     if (dev_infos == nullptr) {
         dev_infos = &sinkList_[0];
-        WARN("Prefered ringtone device %s not found in device list, selecting %s instead.",
+        SFL_WARN("Prefered ringtone device %s not found in device list, selecting %s instead.",
              ringtoneDevice.c_str(), dev_infos->name.c_str());
     }
 
@@ -472,7 +472,7 @@ void PulseLayer::writeToSpeaker()
     int ret = pa_stream_writable_size(s);
 
     if (ret < 0) {
-        ERROR("Playback error : %s", pa_strerror(ret));
+        SFL_ERR("Playback error : %s", pa_strerror(ret));
         return;
     } else if (ret == 0)
         return;
@@ -605,7 +605,7 @@ void PulseLayer::readFromMic()
     mainRingBuffer_->put(*out);
 
     if (pa_stream_drop(record_->pulseStream()) < 0)
-        ERROR("Capture stream drop failed: %s" , pa_strerror(pa_context_errno(context_)));
+        SFL_ERR("Capture stream drop failed: %s" , pa_strerror(pa_context_errno(context_)));
 }
 
 
@@ -620,7 +620,7 @@ void PulseLayer::ringtoneToSpeaker()
     int writable = pa_stream_writable_size(s);
 
     if (writable < 0)
-        ERROR("Ringtone error : %s", pa_strerror(writable));
+        SFL_ERR("Ringtone error : %s", pa_strerror(writable));
 
     if (writable <= 0)
         return;
@@ -657,7 +657,7 @@ PulseLayer::context_changed_callback(pa_context* c,
             switch (type & PA_SUBSCRIPTION_EVENT_TYPE_MASK) {
                 case PA_SUBSCRIPTION_EVENT_NEW:
                 case PA_SUBSCRIPTION_EVENT_REMOVE:
-                    DEBUG("Updating sink list");
+                    SFL_DBG("Updating sink list");
                     context->sinkList_.clear();
                     op = pa_context_get_sink_info_list(c, sink_input_info_callback, userdata);
 
@@ -674,7 +674,7 @@ PulseLayer::context_changed_callback(pa_context* c,
             switch (type & PA_SUBSCRIPTION_EVENT_TYPE_MASK) {
                 case PA_SUBSCRIPTION_EVENT_NEW:
                 case PA_SUBSCRIPTION_EVENT_REMOVE:
-                    DEBUG("Updating source list");
+                    SFL_DBG("Updating source list");
                     context->sourceList_.clear();
                     op = pa_context_get_source_info_list(c, source_input_info_callback, userdata);
 
@@ -688,7 +688,7 @@ PulseLayer::context_changed_callback(pa_context* c,
             break;
 
         default:
-            DEBUG("Unhandled event type 0x%x", type);
+            SFL_DBG("Unhandled event type 0x%x", type);
             break;
     }
 }
@@ -697,7 +697,7 @@ void PulseLayer::server_info_callback(pa_context*, const pa_server_info *i, void
 {
     if (!i) return;
     char s[PA_SAMPLE_SPEC_SNPRINT_MAX], cm[PA_CHANNEL_MAP_SNPRINT_MAX];
-    DEBUG("PulseAudio server info:\n"
+    SFL_DBG("PulseAudio server info:\n"
           "    Server name: %s\n"
           "    Server version: %s\n"
           "    Default Sink %s\n"
@@ -736,7 +736,7 @@ void PulseLayer::source_input_info_callback(pa_context *c UNUSED, const pa_sourc
         return;
     }
 
-    DEBUG("Source %u\n"
+    SFL_DBG("Source %u\n"
           "    Name: %s\n"
           "    Driver: %s\n"
           "    Description: %s\n"
@@ -780,7 +780,7 @@ void PulseLayer::sink_input_info_callback(pa_context *c UNUSED, const pa_sink_in
         return;
     }
 
-    DEBUG("Sink %u\n"
+    SFL_DBG("Sink %u\n"
           "    Name: %s\n"
           "    Driver: %s\n"
           "    Description: %s\n"
@@ -816,17 +816,17 @@ void PulseLayer::updatePreference(AudioPreference &preference, int index, Device
 
     switch (type) {
         case DeviceType::PLAYBACK:
-            DEBUG("setting %s for playback", devName.c_str());
+            SFL_DBG("setting %s for playback", devName.c_str());
             preference.setPulseDevicePlayback(devName);
             break;
 
         case DeviceType::CAPTURE:
-            DEBUG("setting %s for capture", devName.c_str());
+            SFL_DBG("setting %s for capture", devName.c_str());
             preference.setPulseDeviceRecord(devName);
             break;
 
         case DeviceType::RINGTONE:
-            DEBUG("setting %s for ringer", devName.c_str());
+            SFL_DBG("setting %s for ringer", devName.c_str());
             preference.setPulseDeviceRingtone(devName);
             break;
     }
diff --git a/daemon/src/audio/recordable.cpp b/daemon/src/audio/recordable.cpp
index b684579a6a784e9f99fada799355593034ef3a1a..26bd5614c800f04818d8d2558863099dce7d342b 100644
--- a/daemon/src/audio/recordable.cpp
+++ b/daemon/src/audio/recordable.cpp
@@ -35,7 +35,7 @@ namespace sfl {
 
 Recordable::Recordable() : recAudio_(), recorder_(&recAudio_, Manager::instance().getRingBufferPool())
 {
-    DEBUG("Set recording options: %s", Manager::instance().audioPreference.getRecordPath().c_str());
+    SFL_DBG("Set recording options: %s", Manager::instance().audioPreference.getRecordPath().c_str());
     recAudio_.setRecordingOptions(AudioFormat::MONO(), Manager::instance().audioPreference.getRecordPath());
 }
 
diff --git a/daemon/src/audio/resampler.cpp b/daemon/src/audio/resampler.cpp
index 4dfe7596f5b06ec107cf6be515105b57d8a42e9f..0a5dc09b02e4a35c69161449e1818751cacefa46 100644
--- a/daemon/src/audio/resampler.cpp
+++ b/daemon/src/audio/resampler.cpp
@@ -100,10 +100,10 @@ void Resampler::resample(const AudioBuffer &dataIn, AudioBuffer &dataOut)
         // change channel num if needed
         src_state_.reset(new SrcState(nbChans));
         format_.nb_channels = nbChans;
-        DEBUG("SRC channel number changed.");
+        SFL_DBG("SRC channel number changed.");
     }
     if (nbChans != dataOut.channels()) {
-        DEBUG("Output buffer had the wrong number of channels (in: %d, out: %d).", nbChans, dataOut.channels());
+        SFL_DBG("Output buffer had the wrong number of channels (in: %d, out: %d).", nbChans, dataOut.channels());
         dataOut.setChannelNum(nbChans);
     }
 
diff --git a/daemon/src/audio/ringbuffer.cpp b/daemon/src/audio/ringbuffer.cpp
index e21fff3293cc222f63ed9becf158aa0c1a236c3b..2eeb363257b5a0cf2dc171d1d39879dda88592a7 100644
--- a/daemon/src/audio/ringbuffer.cpp
+++ b/daemon/src/audio/ringbuffer.cpp
@@ -94,7 +94,7 @@ size_t RingBuffer::getLength(const std::string &call_id) const
 void
 RingBuffer::debug()
 {
-    DEBUG("Start=%d; End=%d; BufferSize=%d", getSmallestReadOffset(), endPos_, buffer_.frames());
+    SFL_DBG("Start=%d; End=%d; BufferSize=%d", getSmallestReadOffset(), endPos_, buffer_.frames());
 }
 
 size_t RingBuffer::getReadOffset(const std::string &call_id) const
@@ -124,7 +124,7 @@ RingBuffer::storeReadOffset(size_t offset, const std::string &call_id)
     if (iter != readoffsets_.end())
         iter->second = offset;
     else
-        ERROR("RingBuffer::storeReadOffset() failed: unknown call '%s'", call_id.c_str());
+        SFL_ERR("RingBuffer::storeReadOffset() failed: unknown call '%s'", call_id.c_str());
 }
 
 
@@ -230,7 +230,7 @@ size_t RingBuffer::get(AudioBuffer& buf, const std::string &call_id)
     const size_t sample_num = buf.frames();
     size_t toCopy = std::min(sample_num, len);
     if (toCopy and toCopy != sample_num) {
-        DEBUG("Partial get: %d/%d", toCopy, sample_num);
+        SFL_DBG("Partial get: %d/%d", toCopy, sample_num);
     }
 
     const size_t copied = toCopy;
@@ -306,7 +306,7 @@ RingBuffer::discard(size_t toDiscard)
     for (auto & r : readoffsets_) {
         size_t dst = (r.second + buffer_size - endPos_) % buffer_size;
         if (dst < toDiscard) {
-            DEBUG("%s : discarding: %d frames", r.first.c_str(), toDiscard - dst);
+            SFL_DBG("%s : discarding: %d frames", r.first.c_str(), toDiscard - dst);
             r.second = (r.second + toDiscard - dst) % buffer_size;
         }
     }
diff --git a/daemon/src/audio/ringbufferpool.cpp b/daemon/src/audio/ringbufferpool.cpp
index b4b06439079a05d6640b66aea4ad7119a5d1e77c..fdbfd1a6767adf8f41bb4158808c1b1bbb383bb0 100644
--- a/daemon/src/audio/ringbufferpool.cpp
+++ b/daemon/src/audio/ringbufferpool.cpp
@@ -56,7 +56,7 @@ RingBufferPool::~RingBufferPool()
     for (const auto& item : ringBufferMap_) {
         const auto& weak = item.second;
         if (not weak.expired())
-            WARN("Leaking RingBuffer '%s'", item.first.c_str());
+            SFL_WARN("Leaking RingBuffer '%s'", item.first.c_str());
     }
 }
 
@@ -116,12 +116,12 @@ RingBufferPool::createRingBuffer(const std::string& id)
 
     auto rbuf = getRingBuffer(id);
     if (rbuf) {
-        DEBUG("Ringbuffer already exists for id '%s'", id.c_str());
+        SFL_DBG("Ringbuffer already exists for id '%s'", id.c_str());
         return rbuf;
     }
 
     rbuf.reset(new RingBuffer(id, SIZEBUF));
-    DEBUG("Ringbuffer created with id '%s'", id.c_str());
+    SFL_DBG("Ringbuffer created with id '%s'", id.c_str());
     ringBufferMap_.insert(std::make_pair(id, std::weak_ptr<RingBuffer>(rbuf)));
     return rbuf;
 }
@@ -144,7 +144,7 @@ void
 RingBufferPool::removeReadBindings(const std::string& call_id)
 {
     if (not readBindingsMap_.erase(call_id))
-        ERROR("CallID set %s does not exist!", call_id.c_str());
+        SFL_ERR("CallID set %s does not exist!", call_id.c_str());
 }
 
 /**
@@ -155,11 +155,11 @@ RingBufferPool::addReaderToRingBuffer(std::shared_ptr<RingBuffer> rbuf,
                                   const std::string& call_id)
 {
     if (call_id != DEFAULT_ID and rbuf->id == call_id)
-        WARN("RingBuffer has a readoffset on itself");
+        SFL_WARN("RingBuffer has a readoffset on itself");
 
     rbuf->createReadOffset(call_id);
     readBindingsMap_[call_id].insert(rbuf); // bindings list created if not existing
-    DEBUG("Bind rbuf '%s' to callid '%s'", rbuf->id.c_str(), call_id.c_str());
+    SFL_DBG("Bind rbuf '%s' to callid '%s'", rbuf->id.c_str(), call_id.c_str());
 }
 
 void
@@ -181,13 +181,13 @@ RingBufferPool::bindCallID(const std::string& call_id1,
 {
     const auto& rb_call1 = getRingBuffer(call_id1);
     if (not rb_call1) {
-        ERROR("No ringbuffer associated to call '%s'", call_id1.c_str());
+        SFL_ERR("No ringbuffer associated to call '%s'", call_id1.c_str());
         return;
     }
 
     const auto& rb_call2 = getRingBuffer(call_id2);
     if (not rb_call2) {
-        ERROR("No ringbuffer associated to call '%s'", call_id2.c_str());
+        SFL_ERR("No ringbuffer associated to call '%s'", call_id2.c_str());
         return;
     }
 
@@ -216,13 +216,13 @@ RingBufferPool::unBindCallID(const std::string& call_id1,
 {
     const auto& rb_call1 = getRingBuffer(call_id1);
     if (not rb_call1) {
-        ERROR("No ringbuffer associated to call '%s'", call_id1.c_str());
+        SFL_ERR("No ringbuffer associated to call '%s'", call_id1.c_str());
         return;
     }
 
     const auto& rb_call2 = getRingBuffer(call_id2);
     if (not rb_call2) {
-        ERROR("No ringbuffer associated to call '%s'", call_id2.c_str());
+        SFL_ERR("No ringbuffer associated to call '%s'", call_id2.c_str());
         return;
     }
 
@@ -247,7 +247,7 @@ RingBufferPool::unBindAll(const std::string& call_id)
 {
     const auto& rb_call = getRingBuffer(call_id);
     if (not rb_call) {
-        ERROR("No ringbuffer associated to call '%s'", call_id.c_str());
+        SFL_ERR("No ringbuffer associated to call '%s'", call_id.c_str());
         return;
     }
 
diff --git a/daemon/src/audio/sound/audiofile.cpp b/daemon/src/audio/sound/audiofile.cpp
index d7ab0660b6af0932f00d9b3e4a5d1ff43b50d4cc..4b8b253a85228781cf2213d1be1cf5460e3a9e01 100644
--- a/daemon/src/audio/sound/audiofile.cpp
+++ b/daemon/src/audio/sound/audiofile.cpp
@@ -54,7 +54,7 @@ AudioFile::onBufferFinish()
     const int divisor = buffer_->getSampleRate() / 1000;
 
     if (divisor == 0) {
-        ERROR("Error cannot update playback slider, sampling rate is 0");
+        SFL_ERR("Error cannot update playback slider, sampling rate is 0");
         return;
     }
 
@@ -87,7 +87,7 @@ AudioFile::AudioFile(const std::string &fileName, unsigned int sampleRate) :
     } else if (filepath_.find(".ogg") != std::string::npos) {
         format = SF_FORMAT_OGG;
     } else {
-        WARN("No file extension, guessing WAV");
+        SFL_WARN("No file extension, guessing WAV");
         format = SF_FORMAT_WAV;
     }
 
@@ -97,7 +97,7 @@ AudioFile::AudioFile(const std::string &fileName, unsigned int sampleRate) :
     if (!fileHandle)
         throw AudioFileException("File handle " + fileName + " could not be created");
     if (fileHandle.error()) {
-        ERROR("%s", fileHandle.strError());
+        SFL_ERR("%s", fileHandle.strError());
         throw AudioFileException("File " + fileName + " doesn't exist");
     }
 
diff --git a/daemon/src/call.cpp b/daemon/src/call.cpp
index 85367f4a1ab30d78ae9585ea6f5221bd34bec653..3b3aacf4d6ec0bf91bc06df4a292157458c21eea 100644
--- a/daemon/src/call.cpp
+++ b/daemon/src/call.cpp
@@ -123,7 +123,7 @@ Call::setState(CallState state)
         static const char *states[] = {"INACTIVE", "ACTIVE", "HOLD", "BUSY", "ERROR"};
         assert(callState_ < SFL_ARRAYSIZE(states) and state < SFL_ARRAYSIZE(states));
 
-        ERROR("Invalid call state transition from %s to %s",
+        SFL_ERR("Invalid call state transition from %s to %s",
               states[callState_], states[state]);
         return false;
     }
@@ -167,7 +167,7 @@ Call::getStateStr()
                     return "INACTIVE";
             }
 
-        case ERROR:
+        case MERROR:
         default:
             return "FAILURE";
     }
diff --git a/daemon/src/call.h b/daemon/src/call.h
index fb39fc6dc68a0ea7af750e4cf2b88bfb3d5b61da..48d4ed0b3ea09653db57a90b96bcd25b96d53380 100644
--- a/daemon/src/call.h
+++ b/daemon/src/call.h
@@ -78,7 +78,7 @@ class Call : public sfl::Recordable {
         /**
          * The Call State.
          */
-        enum CallState {INACTIVE, ACTIVE, HOLD, BUSY, ERROR};
+        enum CallState {INACTIVE, ACTIVE, HOLD, BUSY, MERROR};
 
         virtual ~Call();
 
diff --git a/daemon/src/call_factory.cpp b/daemon/src/call_factory.cpp
index 3e29a2640a8005aba3d6caeef782a0a267f5f08b..1b2e190b3a063ae410a441c00bd0f91a51d435a5 100644
--- a/daemon/src/call_factory.cpp
+++ b/daemon/src/call_factory.cpp
@@ -44,11 +44,11 @@ CallFactory::removeCall(Call& call)
     std::lock_guard<std::recursive_mutex> lk(callMapsMutex_);
 
     const auto& id = call.getCallId();
-    DEBUG("Removing call %s", id.c_str());
+    SFL_DBG("Removing call %s", id.c_str());
     const auto& account = call.getAccount();
     auto& map = callMaps_.at(account.getAccountType());
     map.erase(id);
-    DEBUG("Remaining %u %s call(s)", map.size(), account.getAccountType());
+    SFL_DBG("Remaining %u %s call(s)", map.size(), account.getAccountType());
 }
 
 void
@@ -59,7 +59,7 @@ CallFactory::removeCall(const std::string& id)
     if (auto call = getCall(id)) {
         removeCall(*call);
     } else
-        ERROR("No call with ID %s", id.c_str());
+        SFL_ERR("No call with ID %s", id.c_str());
 }
 
 //==============================================================================
diff --git a/daemon/src/call_factory.h b/daemon/src/call_factory.h
index fbd6748645f2a06603df06d4078670a1c5452f10..ac5fd38dc9d9cadc99ee4c411bfa7876dfa5c2a6 100644
--- a/daemon/src/call_factory.h
+++ b/daemon/src/call_factory.h
@@ -81,7 +81,7 @@ class CallFactory {
         template <class T, class A>
         std::shared_ptr<T> newCall(A& account, const std::string& id, Call::CallType type) {
             if (!allowNewCall_) {
-                WARN("newCall aborted : CallFactory in forbid state");
+                SFL_WARN("newCall aborted : CallFactory in forbid state");
                 return nullptr;
             }
 
@@ -94,7 +94,7 @@ class CallFactory {
             };
 
             if (hasCall(id)) {
-                ERROR("Call %s is already created", id.c_str());
+                SFL_ERR("Call %s is already created", id.c_str());
                 return nullptr;
             }
 
diff --git a/daemon/src/client/callmanager.cpp b/daemon/src/client/callmanager.cpp
index 176222ad71b11f4b64b2b8028e355d4cf8b39913..f5b8ae8ac744355c3e7211f176268c2be7cf8177 100644
--- a/daemon/src/client/callmanager.cpp
+++ b/daemon/src/client/callmanager.cpp
@@ -56,7 +56,7 @@ bool CallManager::placeCall(const std::string& accountID,
 {
     // Check if a destination number is available
     if (to.empty()) {
-        DEBUG("No number entered - Call stopped");
+        SFL_DBG("No number entered - Call stopped");
         return false;
     } else {
         return Manager::instance().outgoingCall(accountID, callID, to);
@@ -240,7 +240,7 @@ CallManager::getIsRecording(const std::string& callID)
 
 std::string CallManager::getCurrentAudioCodecName(const std::string& /*callID*/)
 {
-    WARN("Deprecated");
+    SFL_WARN("Deprecated");
     return "";
 }
 
@@ -307,7 +307,7 @@ CallManager::setSASVerified(const std::string& callID)
     } catch (...) {
     }
 #else
-    ERROR("No zrtp support for %s, please recompile SFLphone with zrtp", callID.c_str());
+    SFL_ERR("No zrtp support for %s, please recompile SFLphone with zrtp", callID.c_str());
 #endif
 }
 
@@ -322,7 +322,7 @@ CallManager::resetSASVerified(const std::string& callID)
     } catch (...) {
     }
 #else
-    ERROR("No zrtp support for %s, please recompile SFLphone with zrtp", callID.c_str());
+    SFL_ERR("No zrtp support for %s, please recompile SFLphone with zrtp", callID.c_str());
 #endif
 }
 
@@ -337,7 +337,7 @@ CallManager::setConfirmGoClear(const std::string& callID)
     } catch (...) {
     }
 #else
-    ERROR("No zrtp support for %s, please recompile SFLphone with zrtp", callID.c_str());
+    SFL_ERR("No zrtp support for %s, please recompile SFLphone with zrtp", callID.c_str());
 #endif
 }
 
@@ -352,7 +352,7 @@ CallManager::requestGoClear(const std::string& callID)
     } catch (...) {
     }
 #else
-    ERROR("No zrtp support for %s, please recompile SFLphone with zrtp", callID.c_str());
+    SFL_ERR("No zrtp support for %s, please recompile SFLphone with zrtp", callID.c_str());
 #endif
 }
 
@@ -367,7 +367,7 @@ CallManager::acceptEnrollment(const std::string& callID, bool accepted)
     } catch (...) {
     }
 #else
-    ERROR("No zrtp support for %s, please recompile SFLphone with zrtp", callID.c_str());
+    SFL_ERR("No zrtp support for %s, please recompile SFLphone with zrtp", callID.c_str());
 #endif
 }
 
@@ -385,7 +385,7 @@ CallManager::sendTextMessage(const std::string& callID, const std::string& messa
     if (!Manager::instance().sendTextMessage(callID, message, "Me"))
         throw CallManagerException();
 #else
-    ERROR("Could not send \"%s\" text message to %s since SFLphone daemon does not support it, please recompile with instant messaging support", message.c_str(), callID.c_str());
+    SFL_ERR("Could not send \"%s\" text message to %s since SFLphone daemon does not support it, please recompile with instant messaging support", message.c_str(), callID.c_str());
 #endif
 }
 
diff --git a/daemon/src/client/configurationmanager.cpp b/daemon/src/client/configurationmanager.cpp
index 6629d1c297755392cd53e926afb8cc3723b319f7..4a8ebae1a236dfff61f284328d8cfa9a82abf7ee 100644
--- a/daemon/src/client/configurationmanager.cpp
+++ b/daemon/src/client/configurationmanager.cpp
@@ -65,7 +65,7 @@ std::map<std::string, std::string> ConfigurationManager::getIp2IpDetails()
     const auto sipaccount = static_cast<SIPAccount *>(account.get());
 
     if (!sipaccount) {
-        ERROR("Could not find IP2IP account");
+        SFL_ERR("Could not find IP2IP account");
         return std::map<std::string, std::string>();
     } else
         return sipaccount->getIp2IpDetails();
@@ -127,7 +127,7 @@ void ConfigurationManager::setTlsSettings(const std::map<std::string, std::strin
     const auto sipaccount = static_cast<SIPAccount *>(account.get());
 
     if (!sipaccount) {
-        DEBUG("No valid account in set TLS settings");
+        SFL_DBG("No valid account in set TLS settings");
         return;
     }
 
@@ -216,7 +216,7 @@ std::vector<int32_t> ConfigurationManager::getActiveAudioCodecList(const std::st
     if (const auto acc = Manager::instance().getAccount(accountID))
         return acc->getActiveAudioCodecs();
     else {
-        ERROR("Could not find account %s, returning default", accountID.c_str());
+        SFL_ERR("Could not find account %s, returning default", accountID.c_str());
         return Account::getDefaultAudioCodecs();
     }
 }
@@ -227,7 +227,7 @@ void ConfigurationManager::setActiveAudioCodecList(const std::vector<std::string
         acc->setActiveAudioCodecs(list);
         Manager::instance().saveConfig();
     } else {
-        ERROR("Could not find account %s", accountID.c_str());
+        SFL_ERR("Could not find account %s", accountID.c_str());
     }
 }
 
@@ -288,7 +288,7 @@ int32_t ConfigurationManager::getAudioOutputDeviceIndex(const std::string& name)
 
 std::string ConfigurationManager::getCurrentAudioOutputPlugin()
 {
-    DEBUG("Get audio plugin %s", Manager::instance().getCurrentAudioOutputPlugin().c_str());
+    SFL_DBG("Get audio plugin %s", Manager::instance().getCurrentAudioOutputPlugin().c_str());
 
     return Manager::instance().getCurrentAudioOutputPlugin();
 }
@@ -316,11 +316,16 @@ void ConfigurationManager::setAgcState(bool enabled)
 std::map<std::string, std::string> ConfigurationManager::getRingtoneList()
 {
     std::map<std::string, std::string> ringToneList;
+    /* TODO: WINDOWS, Actually move this to GUI, daemon doesn't care. */
+#ifdef __WIN32__
+    return ringToneList;
+#else
+
     std::string r_path(fileutils::get_ringtone_dir());
     struct dirent **namelist;
     int n = scandir(r_path.c_str(), &namelist, 0, alphasort);
     if (n == -1) {
-        ERROR("%s", strerror(errno));
+        SFL_ERR("%s", strerror(errno));
         return ringToneList;
     }
 
@@ -339,6 +344,7 @@ std::map<std::string, std::string> ConfigurationManager::getRingtoneList()
     }
     free(namelist);
     return ringToneList;
+#endif
 }
 
 int32_t ConfigurationManager::isIax2Enabled()
@@ -396,11 +402,11 @@ void ConfigurationManager::setVolume(const std::string& device, double value)
     auto audiolayer = Manager::instance().getAudioDriver();
 
     if (!audiolayer) {
-        ERROR("Audio layer not valid while updating volume");
+        SFL_ERR("Audio layer not valid while updating volume");
         return;
     }
 
-    DEBUG("set volume for %s: %f", device.c_str(), value);
+    SFL_DBG("set volume for %s: %f", device.c_str(), value);
 
     if (device == "speaker") {
         audiolayer->setPlaybackGain(value);
@@ -417,7 +423,7 @@ ConfigurationManager::getVolume(const std::string& device)
     auto audiolayer = Manager::instance().getAudioDriver();
 
     if (!audiolayer) {
-        ERROR("Audio layer not valid while updating volume");
+        SFL_ERR("Audio layer not valid while updating volume");
         return 0.0;
     }
 
@@ -446,7 +452,7 @@ bool ConfigurationManager::isCaptureMuted()
     auto audiolayer = Manager::instance().getAudioDriver();
 
     if (!audiolayer) {
-        ERROR("Audio layer not valid");
+        SFL_ERR("Audio layer not valid");
         return false;
     }
 
@@ -458,7 +464,7 @@ void ConfigurationManager::muteCapture(bool mute)
     auto audiolayer = Manager::instance().getAudioDriver();
 
     if (!audiolayer) {
-        ERROR("Audio layer not valid");
+        SFL_ERR("Audio layer not valid");
         return;
     }
 
@@ -470,7 +476,7 @@ bool ConfigurationManager::isPlaybackMuted()
     auto audiolayer = Manager::instance().getAudioDriver();
 
     if (!audiolayer) {
-        ERROR("Audio layer not valid");
+        SFL_ERR("Audio layer not valid");
         return false;
     }
 
@@ -482,7 +488,7 @@ void ConfigurationManager::mutePlayback(bool mute)
     auto audiolayer = Manager::instance().getAudioDriver();
 
     if (!audiolayer) {
-        ERROR("Audio layer not valid");
+        SFL_ERR("Audio layer not valid");
         return;
     }
 
@@ -565,7 +571,7 @@ bool ConfigurationManager::checkForPrivateKey(const std::string& pemPath)
 #if HAVE_TLS
     return containsPrivateKey(pemPath.c_str()) == 0;
 #else
-    WARN("TLS not supported");
+    SFL_WARN("TLS not supported");
     return false;
 #endif
 }
@@ -577,7 +583,7 @@ bool ConfigurationManager::checkCertificateValidity(const std::string& caPath,
     return certificateIsValid(caPath.size() > 0 ? caPath.c_str() : NULL,
                               pemPath.c_str()) == 0;
 #else
-    WARN("TLS not supported");
+    SFL_WARN("TLS not supported");
     return false;
 #endif
 }
@@ -589,7 +595,7 @@ bool ConfigurationManager::checkHostnameCertificate(const std::string& host,
     return verifyHostnameCertificate(host.c_str(),
                                      strtol(port.c_str(), NULL, 10)) == 0;
 #else
-    WARN("TLS not supported");
+    SFL_WARN("TLS not supported");
     return false;
 #endif
 }
diff --git a/daemon/src/client/presencemanager.cpp b/daemon/src/client/presencemanager.cpp
index b383e8149d48a815834b0d68a76c5874656b45f1..84a526d4d34e49b95d6d1fd2e61ee3f35b9995b7 100644
--- a/daemon/src/client/presencemanager.cpp
+++ b/daemon/src/client/presencemanager.cpp
@@ -63,14 +63,14 @@ PresenceManager::subscribeBuddy(const std::string& accountID, const std::string&
     const auto sipaccount = Manager::instance().getAccount<SIPAccount>(accountID);
 
     if (!sipaccount) {
-        ERROR("Could not find account %s", accountID.c_str());
+        SFL_ERR("Could not find account %s", accountID.c_str());
         return;
     }
 
     auto pres = sipaccount->getPresence();
 
     if (pres and pres->isEnabled() and pres->isSupported(PRESENCE_FUNCTION_SUBSCRIBE)) {
-        DEBUG("%subscribePresence (acc:%s, buddy:%s)", flag ? "S" : "Uns",
+        SFL_DBG("%subscribePresence (acc:%s, buddy:%s)", flag ? "S" : "Uns",
               accountID.c_str(), uri.c_str());
         pres->subscribeClient(uri, flag);
     }
@@ -86,14 +86,14 @@ PresenceManager::publish(const std::string& accountID, bool status, const std::s
     const auto sipaccount = Manager::instance().getAccount<SIPAccount>(accountID);
 
     if (!sipaccount) {
-        ERROR("Could not find account %s.", accountID.c_str());
+        SFL_ERR("Could not find account %s.", accountID.c_str());
         return;
     }
 
     auto pres = sipaccount->getPresence();
 
     if (pres and pres->isEnabled() and pres->isSupported(PRESENCE_FUNCTION_PUBLISH)) {
-        DEBUG("Send Presence (acc:%s, status %s).", accountID.c_str(),
+        SFL_DBG("Send Presence (acc:%s, status %s).", accountID.c_str(),
               status ? "online" : "offline");
         pres->sendPresence(status, note);
     }
@@ -109,17 +109,17 @@ PresenceManager::answerServerRequest(const std::string& uri, bool flag)
     const auto sipaccount = static_cast<SIPAccount *>(account.get());
 
     if (!sipaccount) {
-        ERROR("Could not find account IP2IP");
+        SFL_ERR("Could not find account IP2IP");
         return;
     }
 
-    DEBUG("Approve presence (acc:IP2IP, serv:%s, flag:%s)", uri.c_str(),
+    SFL_DBG("Approve presence (acc:IP2IP, serv:%s, flag:%s)", uri.c_str(),
           flag ? "true" : "false");
 
     auto pres = sipaccount->getPresence();
 
     if (!pres) {
-        ERROR("Presence not initialized");
+        SFL_ERR("Presence not initialized");
         return;
     }
 
@@ -139,7 +139,7 @@ PresenceManager::getSubscriptions(const std::string& accountID)
         const auto pres = sipaccount->getPresence();
 
         if (!pres) {
-            ERROR("Presence not initialized");
+            SFL_ERR("Presence not initialized");
             return ret;
         }
 
@@ -168,7 +168,7 @@ PresenceManager::setSubscriptions(const std::string& accountID, const std::vecto
     auto pres = sipaccount->getPresence();
 
     if (!pres) {
-        ERROR("Presence not initialized");
+        SFL_ERR("Presence not initialized");
         return;
     }
 
diff --git a/daemon/src/client/videomanager.cpp b/daemon/src/client/videomanager.cpp
index f065bacd534327a6aafd7386772aecbff092618a..b3ad383cf1a56e5aab9748f67f63412196256f62 100644
--- a/daemon/src/client/videomanager.cpp
+++ b/daemon/src/client/videomanager.cpp
@@ -94,7 +94,7 @@ VideoManager::getDefaultDevice()
 void
 VideoManager::setDefaultDevice(const std::string &name)
 {
-    DEBUG("Setting device to %s", name.c_str());
+    SFL_DBG("Setting device to %s", name.c_str());
     videoDeviceMonitor_.setDefaultDevice(name);
 }
 
@@ -130,7 +130,7 @@ VideoManager::switchInput(const std::string &resource)
 {
     auto input = videoInput_.lock();
     if (!input) {
-        WARN("Video input not initialized");
+        SFL_WARN("Video input not initialized");
         return false;
     }
     return input->switchInput(resource);
diff --git a/daemon/src/dht/dhtaccount.cpp b/daemon/src/dht/dhtaccount.cpp
index a702885044c221fab1aadf46f874ee35f8145984..3e474595ce12cd3b8491cddbf9941643d8a49aca 100644
--- a/daemon/src/dht/dhtaccount.cpp
+++ b/daemon/src/dht/dhtaccount.cpp
@@ -105,7 +105,7 @@ DHTAccount::DHTAccount(const std::string& accountID, bool /* presenceEnabled */)
 
     int rc = gnutls_global_init();
     if (rc != GNUTLS_E_SUCCESS) {
-        ERROR("Error initializing GnuTLS : %s", gnutls_strerror(rc));
+        SFL_ERR("Error initializing GnuTLS : %s", gnutls_strerror(rc));
         throw VoipLinkException("Can't initialize GnuTLS.");
     }
 }
@@ -131,7 +131,7 @@ DHTAccount::newOutgoingCall(const std::string& id, const std::string& toUrl)
     auto dhtf = toUrl.find("dht:");
     dhtf = (dhtf == std::string::npos) ? 0 : dhtf+4;
     const std::string toUri = toUrl.substr(dhtf, 40);
-    DEBUG("Calling DHT peer %s", toUri.c_str());
+    SFL_DBG("Calling DHT peer %s", toUri.c_str());
     call->setIPToIP(true);
 
     auto resolved = std::make_shared<bool>(false);
@@ -140,17 +140,17 @@ DHTAccount::newOutgoingCall(const std::string& id, const std::string& toUrl)
             if (*resolved)
                 return false;
             for (const auto& v : values) {
-                DEBUG("Resolved value : %s", v->toString().c_str());
+                SFL_DBG("Resolved value : %s", v->toString().c_str());
                 IpAddr peer;
                 try {
                     peer = IpAddr{ dht::ServiceAnnouncement(v->data).getPeerAddr() };
                 } catch (const std::exception& e) {
-                    ERROR("Exception while reading value : %s", e.what());
+                    SFL_ERR("Exception while reading value : %s", e.what());
                     continue;
                 }
                 *resolved = true;
                 std::string toip = getToUri(toUri+"@"+peer.toString(true, true));
-                DEBUG("Got DHT peer IP: %s", toip.c_str());
+                SFL_DBG("Got DHT peer IP: %s", toip.c_str());
                 createOutgoingCall(call, toUri, toip, peer);
                 return false;
             }
@@ -159,7 +159,7 @@ DHTAccount::newOutgoingCall(const std::string& id, const std::string& toUrl)
         [call,resolved] (bool ok){
             if (not *resolved) {
                 call->setConnectionState(Call::DISCONNECTED);
-                call->setState(Call::ERROR);
+                call->setState(Call::MERROR);
             }
         },
         dht::Value::TypeFilter(dht::ServiceAnnouncement::TYPE));
@@ -169,7 +169,7 @@ DHTAccount::newOutgoingCall(const std::string& id, const std::string& toUrl)
 void
 DHTAccount::createOutgoingCall(const std::shared_ptr<SIPCall>& call, const std::string& to, const std::string& toUri, const IpAddr& peer)
 {
-    WARN("DHTAccount::createOutgoingCall to: %s toUri: %s tlsListener: %d", to.c_str(), toUri.c_str(), tlsListener_?1:0);
+    SFL_WARN("DHTAccount::createOutgoingCall to: %s toUri: %s tlsListener: %d", to.c_str(), toUri.c_str(), tlsListener_?1:0);
     std::shared_ptr<SipTransport> t = link_->sipTransport->getTlsTransport(tlsListener_, getToUri(peer.toString(true, true)));
     setTransport(t);
     call->setTransport(t);
@@ -245,13 +245,13 @@ DHTAccount::SIPStartCall(const std::shared_ptr<SIPCall>& call)
     }
 
     const std::string debugContactHeader(pj_strbuf(&pjContact), pj_strlen(&pjContact));
-    DEBUG("contact header: %s / %s -> %s",
+    SFL_DBG("contact header: %s / %s -> %s",
           debugContactHeader.c_str(), from.c_str(), toUri.c_str());
 
     pjsip_dialog *dialog = NULL;
 
     if (pjsip_dlg_create_uac(pjsip_ua_instance(), &pjFrom, &pjContact, &pjTo, NULL, &dialog) != PJ_SUCCESS) {
-        ERROR("Unable to create SIP dialogs for user agent client when "
+        SFL_ERR("Unable to create SIP dialogs for user agent client when "
               "calling %s", toUri.c_str());
         return false;
     }
@@ -263,12 +263,12 @@ DHTAccount::SIPStartCall(const std::shared_ptr<SIPCall>& call)
 
     pjsip_inv_session* inv = nullptr;
     if (pjsip_inv_create_uac(dialog, call->getLocalSDP().getLocalSdpSession(), 0, &inv) != PJ_SUCCESS) {
-        ERROR("Unable to create invite session for user agent client");
+        SFL_ERR("Unable to create invite session for user agent client");
         return false;
     }
 
     if (!inv) {
-        ERROR("Call invite is not initialized");
+        SFL_ERR("Call invite is not initialized");
         return PJ_FALSE;
     }
 
@@ -284,19 +284,19 @@ DHTAccount::SIPStartCall(const std::shared_ptr<SIPCall>& call)
     pjsip_tx_data *tdata;
 
     if (pjsip_inv_invite(call->inv.get(), &tdata) != PJ_SUCCESS) {
-        ERROR("Could not initialize invite messager for this call");
+        SFL_ERR("Could not initialize invite messager for this call");
         return false;
     }
 
     const pjsip_tpselector tp_sel = getTransportSelector();
     if (pjsip_dlg_set_transport(dialog, &tp_sel) != PJ_SUCCESS) {
-        ERROR("Unable to associate transport for invite session dialog");
+        SFL_ERR("Unable to associate transport for invite session dialog");
         return false;
     }
 
     if (pjsip_inv_send_msg(call->inv.get(), tdata) != PJ_SUCCESS) {
         call->inv.reset();
-        ERROR("Unable to send invite message for this call");
+        SFL_ERR("Unable to send invite message for this call");
         return false;
     }
 
@@ -369,7 +369,7 @@ DHTAccount::loadIdentity() const
         }
     }
     catch (const std::exception& e) {
-        ERROR("Error loading identity: %s", e.what());
+        SFL_ERR("Error loading identity: %s", e.what());
         auto id = dht::crypto::generateIdentity();
         if (!id.first || !id.second) {
             throw VoipLinkException("Can't generate identity for this account.");
@@ -383,12 +383,12 @@ DHTAccount::loadIdentity() const
     gnutls_x509_privkey_init(&x509_key);
     int err = gnutls_x509_privkey_import(x509_key, &dt, GNUTLS_X509_FMT_PEM);
     if (err != GNUTLS_E_SUCCESS) {
-        ERROR("Could not read PEM key - %s", gnutls_strerror(err));
+        SFL_ERR("Could not read PEM key - %s", gnutls_strerror(err));
         err = gnutls_x509_privkey_import(x509_key, &dt, GNUTLS_X509_FMT_DER);
     }
     if (err != GNUTLS_E_SUCCESS) {
         gnutls_x509_privkey_deinit(x509_key);
-        ERROR("Could not read key - %s", gnutls_strerror(err));
+        SFL_ERR("Could not read key - %s", gnutls_strerror(err));
         return {};
     }
 
@@ -398,13 +398,13 @@ DHTAccount::loadIdentity() const
     gnutls_datum_t crt_dt {reinterpret_cast<uint8_t*>(buffer_crt.data()), static_cast<unsigned>(buffer_crt.size())};
     err = gnutls_x509_crt_import(certificate, &crt_dt, GNUTLS_X509_FMT_PEM);
     if (err != GNUTLS_E_SUCCESS) {
-        ERROR("Could not read PEM certificate - %s", gnutls_strerror(err));
+        SFL_ERR("Could not read PEM certificate - %s", gnutls_strerror(err));
         err = gnutls_x509_crt_import(certificate, &crt_dt, GNUTLS_X509_FMT_DER);
     }
     if (err != GNUTLS_E_SUCCESS) {
         gnutls_x509_privkey_deinit(x509_key);
         gnutls_x509_crt_deinit(certificate);
-        ERROR("Could not read key - %s", gnutls_strerror(err));
+        SFL_ERR("Could not read key - %s", gnutls_strerror(err));
         return {};
     }
 
@@ -418,7 +418,7 @@ DHTAccount::saveIdentity(const dht::crypto::Identity id) const
         auto buffer = id.first->serialize();
         std::ofstream file(privkeyPath_, std::ios::trunc | std::ios::binary);
         if (!file.is_open()) {
-            ERROR("Could not write key to %s", privkeyPath_.c_str());
+            SFL_ERR("Could not write key to %s", privkeyPath_.c_str());
             return;
         }
         file.write((char*)buffer.data(), buffer.size());
@@ -428,7 +428,7 @@ DHTAccount::saveIdentity(const dht::crypto::Identity id) const
         auto buffer = id.second->getPacked();
         std::ofstream file(certPath_, std::ios::trunc | std::ios::binary);
         if (!file.is_open()) {
-            ERROR("Could not write key to %s", certPath_.c_str());
+            SFL_ERR("Could not write key to %s", certPath_.c_str());
             return;
         }
         file.write((char*)buffer.data(), buffer.size());
@@ -441,7 +441,7 @@ parseInt(const std::map<std::string, std::string> &details, const char *key, T &
 {
     const auto iter = details.find(key);
     if (iter == details.end()) {
-        ERROR("Couldn't find key %s", key);
+        SFL_ERR("Couldn't find key %s", key);
         return;
     }
     i = atoi(iter->second.c_str());
@@ -467,17 +467,17 @@ std::map<std::string, std::string> DHTAccount::getAccountDetails() const
 void DHTAccount::doRegister()
 {
     if (not isEnabled()) {
-        WARN("Account must be enabled to register, ignoring");
+        SFL_WARN("Account must be enabled to register, ignoring");
         return;
     }
 
     try {
         if (dht_.isRunning()) {
-            ERROR("DHT already running (stopping it first).");
+            SFL_ERR("DHT already running (stopping it first).");
             dht_.join();
         }
         dht_.run(dhtPort_, loadIdentity(), [=](dht::Dht::Status s4, dht::Dht::Status s6) {
-            WARN("Dht status : %d %d", (int)s4, (int)s6);
+            SFL_WARN("Dht status : %d %d", (int)s4, (int)s6);
             auto status = std::max(s4, s6);
             switch(status) {
             case dht::Dht::Status::Connecting:
@@ -490,7 +490,7 @@ void DHTAccount::doRegister()
                         getTlsSetting());
                     if (!tlsListener_) {
                         setRegistrationState(RegistrationState::ERROR_GENERIC);
-                        ERROR("Error creating TLS listener.");
+                        SFL_ERR("Error creating TLS listener.");
                         return;
                     }
                 }
@@ -506,7 +506,7 @@ void DHTAccount::doRegister()
         dht_.importValues(loadValues());
 
         dht_.put(dht_.getId(), dht::Value{dht::ServiceAnnouncement::TYPE.id, dht::ServiceAnnouncement(getTlsListenerPort())}, [](bool ok) {
-            DEBUG("Peer announce callback ! %d", ok);
+            SFL_DBG("Peer announce callback ! %d", ok);
         });
 
         username_ = dht_.getId().toString();
@@ -524,12 +524,12 @@ void DHTAccount::doRegister()
                 bootstrap.insert(bootstrap.end(), ips.begin(), ips.end());
             }
             for (auto ip : bootstrap)
-                DEBUG("Bootstrap node: %s", IpAddr(ip).toString(true).c_str());
+                SFL_DBG("Bootstrap node: %s", IpAddr(ip).toString(true).c_str());
             dht_.bootstrap(bootstrap);
         }
     }
     catch (const std::exception& e) {
-        ERROR("Error registering DHT account: %s", e.what());
+        SFL_ERR("Error registering DHT account: %s", e.what());
         setRegistrationState(RegistrationState::ERROR_GENERIC);
     }
 }
@@ -555,7 +555,7 @@ void DHTAccount::saveNodes(const std::vector<dht::Dht::NodeExport>& nodes) const
     {
         std::ofstream file(nodesPath, std::ios::trunc);
         if (!file.is_open()) {
-            ERROR("Could not save nodes to %s", nodesPath.c_str());
+            SFL_ERR("Could not save nodes to %s", nodesPath.c_str());
             return;
         }
         for (auto& n : nodes)
@@ -580,7 +580,7 @@ DHTAccount::loadNodes() const
     {
         std::ifstream file(nodesPath);
         if (!file.is_open()) {
-            ERROR("Could not load nodes from %s", nodesPath.c_str());
+            SFL_ERR("Could not load nodes from %s", nodesPath.c_str());
             return nodes;
         }
         std::string line;
@@ -602,7 +602,7 @@ DHTAccount::loadValues() const
     struct dirent *entry;
     DIR *dp = opendir(dataPath_.c_str());
     if (!dp) {
-        ERROR("Could not load values from %s", dataPath_.c_str());
+        SFL_ERR("Could not load values from %s", dataPath_.c_str());
         return {};
     }
 
@@ -616,7 +616,7 @@ DHTAccount::loadValues() const
             std::istreambuf_iterator<char> begin(ifs), end;
             values.push_back({{fname}, std::vector<uint8_t>{begin, end}});
         } catch (const std::exception& e) {
-            ERROR("Error reading value: %s", e.what());
+            SFL_ERR("Error reading value: %s", e.what());
             continue;
         }
     }
@@ -647,7 +647,7 @@ void DHTAccount::initTlsConfiguration()
 
 void DHTAccount::loadConfig()
 {
-    WARN("DHTAccount::loadConfig()");
+    SFL_WARN("DHTAccount::loadConfig()");
     initTlsConfiguration();
     transportType_ = PJSIP_TRANSPORT_TLS;
 }
@@ -661,7 +661,7 @@ MatchRank
 DHTAccount::matches(const std::string &userName, const std::string &server) const
 {
     if (userMatch(userName)) {
-        DEBUG("Matching account id in request with username %s", userName.c_str());
+        SFL_DBG("Matching account id in request with username %s", userName.c_str());
         return MatchRank::FULL;
     } else {
         return MatchRank::NONE;
@@ -687,7 +687,7 @@ DHTAccount::getContactHeader(pjsip_transport* t)
     if (!t && transport_)
         t = transport_->get();
     if (!t)
-        ERROR("Transport not created yet");
+        SFL_ERR("Transport not created yet");
 
     // The transport type must be specified, in our case START_OTHER refers to stun transport
     pjsip_transport_type_e transportType = transportType_;
@@ -708,7 +708,7 @@ DHTAccount::getContactHeader(pjsip_transport* t)
     }
 #endif
 
-    WARN("getContactHeader %s@%s:%d", username_.c_str(), address.c_str(), port);
+    SFL_WARN("getContactHeader %s@%s:%d", username_.c_str(), address.c_str(), port);
     contact_.slen = pj_ansi_snprintf(contact_.ptr, PJSIP_MAX_URL_SIZE,
                                      "<sips:%s%s%s:%d;transport=%s>",
                                      username_.c_str(),
@@ -744,4 +744,4 @@ void DHTAccount::updateDialogViaSentBy(pjsip_dialog *dlg)
     if (allowViaRewrite_ && via_addr_.host.slen > 0)
         pjsip_dlg_set_via_sent_by(dlg, &via_addr_, via_tp_);
 }
-*/
\ No newline at end of file
+*/
diff --git a/daemon/src/dht/dhtcpp/crypto.cpp b/daemon/src/dht/dhtcpp/crypto.cpp
index 76dd2ba79cda09ed3d8c8c04717f2a517452064e..d80dc7a6b5c92da66463f5b0ffcbbb1e919e719e 100644
--- a/daemon/src/dht/dhtcpp/crypto.cpp
+++ b/daemon/src/dht/dhtcpp/crypto.cpp
@@ -39,7 +39,7 @@ static gnutls_digest_algorithm_t get_dig_for_pub(gnutls_pubkey_t pubkey)
     gnutls_digest_algorithm_t dig;
     int result = gnutls_pubkey_get_preferred_hash_algorithm(pubkey, &dig, nullptr);
     if (result < 0) {
-        ERROR("crt_get_preferred_hash_algorithm: %s\n", gnutls_strerror(result));
+        SFL_ERR("crt_get_preferred_hash_algorithm: %s\n", gnutls_strerror(result));
         return GNUTLS_DIG_UNKNOWN;
     }
     return dig;
@@ -52,7 +52,7 @@ static gnutls_digest_algorithm_t get_dig(gnutls_x509_crt_t crt)
 
     int result = gnutls_pubkey_import_x509(pubkey, crt, 0);
     if (result < 0) {
-        ERROR("gnutls_pubkey_import_x509: %s\n", gnutls_strerror(result));
+        SFL_ERR("gnutls_pubkey_import_x509: %s\n", gnutls_strerror(result));
         return GNUTLS_DIG_UNKNOWN;
     }
 
@@ -235,7 +235,7 @@ Certificate::getPublicKey() const
 crypto::Identity
 generateIdentity()
 {
-    WARN("SecureDht: generating a new identity (2048 bits RSA key pair and self-signed certificate).");
+    SFL_WARN("SecureDht: generating a new identity (2048 bits RSA key pair and self-signed certificate).");
     gnutls_x509_privkey_t key;
     gnutls_privkey_t pkey;
     if (gnutls_x509_privkey_init(&key) != GNUTLS_E_SUCCESS)
diff --git a/daemon/src/dht/dhtcpp/dht.cpp b/daemon/src/dht/dhtcpp/dht.cpp
index 8d136b74079871ee07fa800bef3daf1ea09c193e..1ac7aa136c1482aafd33b4529079a9b6a5faf2d6 100644
--- a/daemon/src/dht/dhtcpp/dht.cpp
+++ b/daemon/src/dht/dhtcpp/dht.cpp
@@ -114,7 +114,7 @@ debug_printable(const uint8_t *buf, unsigned buflen)
     std::string buf_clean(buflen, '\0');
     for (unsigned i=0; i<buflen; i++)
         buf_clean[i] = buf[i] >= 32 && buf[i] <= 126 ? buf[i] : '.';
-    DEBUG("%s", buf_clean.c_str());
+    SFL_DBG("%s", buf_clean.c_str());
 }
 
 namespace dht {
@@ -298,7 +298,7 @@ Dht::sendCachedPing(Bucket& b)
     if (b.cached.ss_family == 0)
         return 0;
 
-    DEBUG("Sending ping to cached node.");
+    SFL_DBG("Sending ping to cached node.");
     int rc = sendPing((sockaddr*)&b.cached, b.cachedlen, TransId{TransPrefix::PING});
     b.cached.ss_family = 0;
     b.cachedlen = 0;
@@ -321,7 +321,7 @@ Dht::pinged(Node& n, Bucket *b)
 void
 Dht::blacklistNode(const InfoHash* id, const sockaddr *sa, socklen_t salen)
 {
-    DEBUG("Blacklisting broken node.");
+    SFL_DBG("Blacklisting broken node.");
 
     if (id) {
         /* Make the node easy to discard. */
@@ -405,7 +405,7 @@ Dht::newNode(const InfoHash& id, const sockaddr *sa, socklen_t salen, int confir
     if (confirm == 2)
         b->time = now.tv_sec;
 
-    DEBUG("Dht::newNode %s", id.toString().c_str());
+    SFL_DBG("Dht::newNode %s", id.toString().c_str());
 
     for (auto& n : b->nodes) {
         if (n.id != id) continue;
@@ -425,7 +425,7 @@ Dht::newNode(const InfoHash& id, const sockaddr *sa, socklen_t salen, int confir
                     if (s.af != sa->sa_family) continue;
                     if (s.insertNode(id, sa, salen, now.tv_sec, true)) {
                         time_t tm = s.getNextStepTime(types, now.tv_sec);
-                        WARN("Resurrect node  ! (%lu, in %lu sec)", tm, tm - now.tv_sec);
+                        SFL_WARN("Resurrect node  ! (%lu, in %lu sec)", tm, tm - now.tv_sec);
                         if (tm != 0 && (search_time == 0 || search_time > tm))
                             search_time = tm;
                     }
@@ -436,14 +436,14 @@ Dht::newNode(const InfoHash& id, const sockaddr *sa, socklen_t salen, int confir
     }
 
     /* New node. */
-    DEBUG("New node!");
+    SFL_DBG("New node!");
 
     /* Try adding the node to searches */
     for (auto& s : searches) {
         if (s.af != sa->sa_family) continue;
         if (s.insertNode(id, sa, salen, now.tv_sec)) {
             time_t tm = s.getNextStepTime(types, now.tv_sec);
-            DEBUG("Inserted node the new way ! (%lu, in %lu sec)", tm, tm - now.tv_sec);
+            SFL_DBG("Inserted node the new way ! (%lu, in %lu sec)", tm, tm - now.tv_sec);
             if (tm != 0 && (search_time == 0 || search_time > tm))
                 search_time = tm;
         }
@@ -480,7 +480,7 @@ Dht::newNode(const InfoHash& id, const sockaddr *sa, socklen_t salen, int confir
             if (!n.isGood(now.tv_sec)) {
                 dubious = true;
                 if (n.pinged_time < now.tv_sec - 15) {
-                    DEBUG("Sending ping to dubious node.");
+                    SFL_DBG("Sending ping to dubious node.");
                     sendPing((sockaddr*)&n.ss, n.sslen, TransId {TransPrefix::PING});
                     n.pinged++;
                     n.pinged_time = now.tv_sec;
@@ -490,7 +490,7 @@ Dht::newNode(const InfoHash& id, const sockaddr *sa, socklen_t salen, int confir
         }
 
         if (mybucket && (!dubious || list.size() == 1)) {
-            DEBUG("Splitting.");
+            SFL_DBG("Splitting.");
             sendCachedPing(*b);
             list.split(b);
             dumpTables();
@@ -507,7 +507,7 @@ Dht::newNode(const InfoHash& id, const sockaddr *sa, socklen_t salen, int confir
     }
 
     /* Create a new node. */
-    //DEBUG("New node! - allocation");
+    //SFL_DBG("New node! - allocation");
     b->nodes.emplace_front(id, sa, salen, confirm ? now.tv_sec : 0, confirm >= 2 ? now.tv_sec : 0);
     return &b->nodes.front();
 }
@@ -557,7 +557,7 @@ Dht::Search::insertNode(const InfoHash& nid,
     time_t now, bool confirmed, const Blob& token)
 {
     if (sa->sa_family != af) {
-        DEBUG("Attempted to insert node in the wrong family.");
+        SFL_DBG("Attempted to insert node in the wrong family.");
         return false;
     }
 
@@ -581,7 +581,7 @@ Dht::Search::insertNode(const InfoHash& nid,
             nodes.pop_back();
     }
 
-    DEBUG("Search::insertNode %s", nid.toString().c_str());
+    SFL_DBG("Search::insertNode %s", nid.toString().c_str());
 
     memcpy(&n->ss, sa, salen);
     n->sslen = salen;
@@ -596,7 +596,7 @@ Dht::Search::insertNode(const InfoHash& nid,
         n->request_time = 0;
       /*  n->pinged = 0;*/
         if (token.size() > 64)
-            DEBUG("Eek!  Overlong token.");
+            SFL_DBG("Eek!  Overlong token.");
         else
             n->token = token;
     }
@@ -632,7 +632,7 @@ Dht::searchSendGetValues(Search& sr, SearchNode *n)
         char hbuf[NI_MAXHOST];
         char sbuf[NI_MAXSERV];
         getnameinfo((sockaddr*)&n->ss, n->sslen, hbuf, sizeof(hbuf), sbuf, sizeof(sbuf), NI_NUMERICHOST | NI_NUMERICSERV);
-        WARN("Sending get_values to %s:%s for %s.", hbuf, sbuf, n->id.toString().c_str());
+        SFL_WARN("Sending get_values to %s:%s for %s.", hbuf, sbuf, n->id.toString().c_str());
     }
     sendGetValues((sockaddr*)&n->ss, n->sslen, TransId {TransPrefix::GET_VALUES, sr.tid}, sr.id, -1, n->reply_time >= t - 15);
     n->pinged++;
@@ -657,7 +657,7 @@ Dht::searchStep(Search& sr)
         if (sr.step_time == 0)
             sr.step_time = now.tv_sec;
         if (now.tv_sec - sr.step_time > SEARCH_TIMEOUT) {
-            WARN("Search timed out.");
+            SFL_WARN("Search timed out.");
             if (sr.done_callback)
                 sr.done_callback(false);
             if (sr.announce.empty())
@@ -669,11 +669,11 @@ Dht::searchStep(Search& sr)
 
     /* Check if the first 8 live nodes have replied. */
     if (sr.isSynced(now.tv_sec)) {
-        DEBUG("searchStep (synced).");
+        SFL_DBG("searchStep (synced).");
         for (auto& a : sr.announce) {
             if (!a.value) {
                 continue;
-                ERROR("Trying to announce a null value !");
+                SFL_ERR("Trying to announce a null value !");
             }
             unsigned i = 0;
             bool all_acked = true;
@@ -699,7 +699,7 @@ Dht::searchStep(Search& sr)
                         char hbuf[NI_MAXHOST];
                         char sbuf[NI_MAXSERV];
                         getnameinfo((sockaddr*)&n.ss, n.sslen, hbuf, sizeof(hbuf), sbuf, sizeof(sbuf), NI_NUMERICHOST | NI_NUMERICSERV);
-                        WARN("Sending announce_value to %s:%s (%s).", hbuf, sbuf, n.id.toString().c_str());
+                        SFL_WARN("Sending announce_value to %s:%s (%s).", hbuf, sbuf, n.id.toString().c_str());
                     }
                     sendAnnounceValue((sockaddr*)&n.ss, sizeof(sockaddr_storage),
                                        TransId {TransPrefix::ANNOUNCE_VALUES, sr.tid}, sr.id, *a.value,
@@ -728,7 +728,7 @@ Dht::searchStep(Search& sr)
                     pinged(*node);
             }
         }
-        DEBUG("Search done.");
+        SFL_DBG("Search done.");
         if (sr.done_callback) {
             sr.done_callback(true);
             sr.done_callback = nullptr;
@@ -736,7 +736,7 @@ Dht::searchStep(Search& sr)
         if (sr.announce.empty())
             sr.done = true;
     } else {
-        DEBUG("searchStep.");
+        SFL_DBG("searchStep.");
         if (sr.step_time + SEARCH_GET_STEP >= now.tv_sec)
             return;
         if (sr.nodes.empty() && sr.announce.empty()) {
@@ -755,7 +755,7 @@ Dht::searchStep(Search& sr)
     {
         std::stringstream out;
         dumpSearch(sr, out);
-        DEBUG("%s", out.str().c_str());
+        SFL_DBG("%s", out.str().c_str());
     }
 }
 
@@ -848,7 +848,7 @@ Dht::bootstrapSearch(Dht::Search& sr)
     auto& list = (sr.af == AF_INET) ? buckets : buckets6;
     if (list.empty() || (list.size() == 1 && list.front().nodes.empty()))
         return;
-    DEBUG("bootstrapSearch.");
+    SFL_DBG("bootstrapSearch.");
     auto b = list.findBucket(sr.id);
     if (b == list.end())
         return;
@@ -872,7 +872,7 @@ Dht::Search*
 Dht::search(const InfoHash& id, sa_family_t af, GetCallback callback, DoneCallback done_callback, Value::Filter filter)
 {
     if (!isRunning(af)) {
-        ERROR("Unsupported protocol IPv%s bucket for %s", (af == AF_INET) ? "4" : "6", id.toString().c_str());
+        SFL_ERR("Unsupported protocol IPv%s bucket for %s", (af == AF_INET) ? "4" : "6", id.toString().c_str());
         if (done_callback)
             done_callback(false);
         return nullptr;
@@ -914,7 +914,7 @@ Dht::search(const InfoHash& id, sa_family_t af, GetCallback callback, DoneCallba
         sr->id = id;
         sr->done = false;
         sr->nodes = {};
-        DEBUG("New IPv%s search for %s", (af == AF_INET) ? "4" : "6", id.toString().c_str());
+        SFL_DBG("New IPv%s search for %s", (af == AF_INET) ? "4" : "6", id.toString().c_str());
     }
 
     if (callback)
@@ -968,7 +968,7 @@ Dht::put(const InfoHash& id, Value&& value, DoneCallback callback)
         value.owner = getId();
 */
     auto val = std::make_shared<Value>(std::move(value));
-    DEBUG("put: adding %s -> %s", id.toString().c_str(), val->toString().c_str());
+    SFL_DBG("put: adding %s -> %s", id.toString().c_str(), val->toString().c_str());
 
     auto ok = std::make_shared<bool>(false);
     auto done = std::make_shared<bool>(false);
@@ -982,13 +982,13 @@ Dht::put(const InfoHash& id, Value&& value, DoneCallback callback)
         }
     };
     announce(id, AF_INET, val, [=](bool ok4) {
-        DEBUG("search done IPv4 %d", ok4);
+        SFL_DBG("search done IPv4 %d", ok4);
         *done4 = true;
         *ok |= ok4;
         donecb();
     });
     announce(id, AF_INET6, val, [=](bool ok6) {
-        DEBUG("search done IPv6 %d", ok6);
+        SFL_DBG("search done IPv6 %d", ok6);
         *done6 = true;
         *ok |= ok6;
         donecb();
@@ -1002,7 +1002,7 @@ Dht::get(const InfoHash& id, GetCallback getcb, DoneCallback donecb, Value::Filt
     if (getcb) {
         auto locVals = getLocal(id, filter);
         if (not locVals.empty()) {
-            DEBUG("Found local data (%d values).", locVals.size());
+            SFL_DBG("Found local data (%d values).", locVals.size());
             getcb(locVals);
         }
     }
@@ -1079,7 +1079,7 @@ Dht::storageStore(const InfoHash& id, const std::shared_ptr<Value>& value)
         it->time = now.tv_sec;
         return &*it;
     } else {
-        DEBUG("Storing %s -> %s", id.toString().c_str(), value->toString().c_str());
+        SFL_DBG("Storing %s -> %s", id.toString().c_str(), value->toString().c_str());
         if (st->values.size() >= MAX_VALUES)
             return nullptr;
         st->values.emplace_back(value, now.tv_sec);
@@ -1101,13 +1101,13 @@ Dht::expireStorage()
                     const auto& type = getType(v.data->type);
                     bool expired = v.time + type.expiration < now.tv_sec;
                     if (expired)
-                        DEBUG("Discarding expired value %s", v.data->toString().c_str());
+                        SFL_DBG("Discarding expired value %s", v.data->toString().c_str());
                     return !expired;
                 }),
             i->values.end());
 
         if (i->values.size() == 0) {
-            DEBUG("Discarding expired value %s", i->id.toString().c_str());
+            SFL_DBG("Discarding expired value %s", i->id.toString().c_str());
             i = store.erase(i);
         }
         else
@@ -1307,7 +1307,7 @@ Dht::dumpTables() const
     }
 
     //out << std::endl << std::endl;
-    DEBUG("%s", out.str().c_str());
+    SFL_DBG("%s", out.str().c_str());
 }
 
 
@@ -1356,7 +1356,7 @@ Dht::Dht(int s, int s6, const InfoHash& id, const unsigned char *v)
     expireBuckets(buckets);
     expireBuckets(buckets6);
 
-    DEBUG("DHT initialised with node ID %s", myid.toString().c_str());
+    SFL_DBG("DHT initialised with node ID %s", myid.toString().c_str());
 }
 
 
@@ -1383,7 +1383,7 @@ Dht::rateLimit()
 bool
 Dht::neighbourhoodMaintenance(RoutingTable& list)
 {
-    DEBUG("neighbourhoodMaintenance");
+    SFL_DBG("neighbourhoodMaintenance");
 
     auto b = list.findBucket(myid);
     if (b == list.end())
@@ -1407,7 +1407,7 @@ Dht::neighbourhoodMaintenance(RoutingTable& list)
     int want = dht_socket >= 0 && dht_socket6 >= 0 ? (WANT4 | WANT6) : -1;
     Node *n = q->randomNode();
     if (n) {
-        DEBUG("Sending find_node for%s neighborhood maintenance.", q->af == AF_INET6 ? " IPv6" : "");
+        SFL_DBG("Sending find_node for%s neighborhood maintenance.", q->af == AF_INET6 ? " IPv6" : "");
         sendFindNode((sockaddr*)&n->ss, n->sslen,
                        TransId {TransPrefix::FIND_NODE}, id, want,
                        n->reply_time >= now.tv_sec - 15);
@@ -1459,7 +1459,7 @@ Dht::bucketMaintenance(RoutingTable& list)
                         want = WANT4 | WANT6;
                 }
 
-                DEBUG("Sending find_node for%s bucket maintenance.", q->af == AF_INET6 ? " IPv6" : "");
+                SFL_DBG("Sending find_node for%s bucket maintenance.", q->af == AF_INET6 ? " IPv6" : "");
                 sendFindNode((sockaddr*)&n->ss, n->sslen,
                                TransId {TransPrefix::FIND_NODE}, id, want,
                                n->reply_time >= now.tv_sec - 15);
@@ -1468,7 +1468,7 @@ Dht::bucketMaintenance(RoutingTable& list)
                    give up for now and reschedule us soon. */
                 return true;
             } else {
-                //DEBUG("Bucket maintenance %s: no suitable node", q->af == AF_INET ? "IPv4" : "IPv6");
+                //SFL_DBG("Bucket maintenance %s: no suitable node", q->af == AF_INET ? "IPv4" : "IPv6");
             }
         }
     }
@@ -1481,7 +1481,7 @@ Dht::processMessage(const uint8_t *buf, size_t buflen, const sockaddr *from, soc
     if (buflen == 0)
         return;
 
-    //DEBUG("processMessage %p %lu %p %lu", buf, buflen, from, fromlen);
+    //SFL_DBG("processMessage %p %lu %p %lu", buf, buflen, from, fromlen);
 
     MessageType message;
     InfoHash id, info_hash, target;
@@ -1502,7 +1502,7 @@ Dht::processMessage(const uint8_t *buf, size_t buflen, const sockaddr *from, soc
         return;
 
     if (isNodeBlacklisted(from, fromlen)) {
-        DEBUG("Received packet from blacklisted node.");
+        SFL_DBG("Received packet from blacklisted node.");
         return;
     }
 
@@ -1517,21 +1517,21 @@ Dht::processMessage(const uint8_t *buf, size_t buflen, const sockaddr *from, soc
         if (message != MessageType::Error && id == zeroes)
             throw DhtException("no or invalid InfoHash");
     } catch (const std::exception& e) {
-        DEBUG("Can't process message of size %lu: %s.", buflen, e.what());
+        SFL_DBG("Can't process message of size %lu: %s.", buflen, e.what());
         debug_printable(buf, buflen);
-        //DEBUG("");
+        //SFL_DBG("");
         return;
     }
 
     if (id == myid) {
-        DEBUG("Received message from self.");
+        SFL_DBG("Received message from self.");
         return;
     }
 
     if (message > MessageType::Reply) {
         /* Rate limit requests. */
         if (!rateLimit()) {
-            DEBUG("Dropping request due to rate limiting.");
+            SFL_DBG("Dropping request due to rate limiting.");
             return;
         }
     }
@@ -1539,7 +1539,7 @@ Dht::processMessage(const uint8_t *buf, size_t buflen, const sockaddr *from, soc
     switch (message) {
     case MessageType::Error:
         if (tid.length != 4) return;
-        DEBUG("Received error message:");
+        SFL_DBG("Received error message:");
         debug_printable(buf, buflen);
         if (error_code == 401 && id != zeroes && tid.matches(TransPrefix::ANNOUNCE_VALUES, &ttid)) {
             auto sr = findSearch(ttid, from->sa_family);
@@ -1556,9 +1556,9 @@ Dht::processMessage(const uint8_t *buf, size_t buflen, const sockaddr *from, soc
         break;
     case MessageType::Reply:
         if (tid.length != 4) {
-            DEBUG("Broken node truncates transaction ids: ");
+            SFL_DBG("Broken node truncates transaction ids: ");
             debug_printable(buf, buflen);
-            DEBUG("\n");
+            SFL_DBG("\n");
             /* This is really annoying, as it means that we will
                time-out all our searches that go through this node.
                Kill it. */
@@ -1566,7 +1566,7 @@ Dht::processMessage(const uint8_t *buf, size_t buflen, const sockaddr *from, soc
             return;
         }
         if (tid.matches(TransPrefix::PING)) {
-            DEBUG("Pong!");
+            SFL_DBG("Pong!");
             newNode(id, from, fromlen, 2);
         } else if (tid.matches(TransPrefix::FIND_NODE) or tid.matches(TransPrefix::GET_VALUES)) {
             bool gp = false;
@@ -1575,12 +1575,12 @@ Dht::processMessage(const uint8_t *buf, size_t buflen, const sockaddr *from, soc
                 gp = true;
                 sr = findSearch(ttid, from->sa_family);
             }
-            DEBUG("Nodes found (%u+%u)%s!", nodes_len/26, nodes6_len/38, gp ? " for get_values" : "");
+            SFL_DBG("Nodes found (%u+%u)%s!", nodes_len/26, nodes6_len/38, gp ? " for get_values" : "");
             if (nodes_len % 26 != 0 || nodes6_len % 38 != 0) {
-                DEBUG("Unexpected length for node info!");
+                SFL_DBG("Unexpected length for node info!");
                 blacklistNode(&id, from, fromlen);
             } else if (gp && sr == NULL) {
-                DEBUG("Unknown search!");
+                SFL_DBG("Unknown search!");
                 newNode(id, from, fromlen, 1);
             } else {
                 newNode(id, from, fromlen, 2);
@@ -1615,7 +1615,7 @@ Dht::processMessage(const uint8_t *buf, size_t buflen, const sockaddr *from, soc
                        requests in flight has decreased.  Let's push
                        another request. */
                     /*if (sr->isSynced(now.tv_sec)) {
-                        DEBUG("Trying to accelerate search!");
+                        SFL_DBG("Trying to accelerate search!");
                         search_time = now.tv_sec;
                         //sr->step_time = 0;
                     } else {*/
@@ -1626,7 +1626,7 @@ Dht::processMessage(const uint8_t *buf, size_t buflen, const sockaddr *from, soc
             if (sr) {
                 sr->insertNode(id, from, fromlen, now.tv_sec, true, token);
                 if (!values.empty()) {
-                    DEBUG("Got %d values !", values.size());
+                    SFL_DBG("Got %d values !", values.size());
                     for (auto& cb : sr->callbacks) {
                         if (!cb.second) continue;
                         std::vector<std::shared_ptr<Value>> tmp;
@@ -1643,10 +1643,10 @@ Dht::processMessage(const uint8_t *buf, size_t buflen, const sockaddr *from, soc
                 }
             }
         } else if (tid.matches(TransPrefix::ANNOUNCE_VALUES, &ttid)) {
-            DEBUG("Got reply to announce_values.");
+            SFL_DBG("Got reply to announce_values.");
             Search *sr = findSearch(ttid, from->sa_family);
             if (!sr || value_id == Value::INVALID_ID) {
-                DEBUG("Unknown search or announce!");
+                SFL_DBG("Unknown search or announce!");
                 newNode(id, from, fromlen, 1);
             } else {
                 newNode(id, from, fromlen, 2);
@@ -1666,64 +1666,64 @@ Dht::processMessage(const uint8_t *buf, size_t buflen, const sockaddr *from, soc
                 searchSendGetValues(*sr);
             }
         } else {
-            DEBUG("Unexpected reply: ");
+            SFL_DBG("Unexpected reply: ");
             debug_printable(buf, buflen);
-            DEBUG("\n");
+            SFL_DBG("\n");
         }
         break;
     case MessageType::Ping:
-        DEBUG("Got ping (%d)!", tid.length);
+        SFL_DBG("Got ping (%d)!", tid.length);
         newNode(id, from, fromlen, 1);
-        DEBUG("Sending pong.");
+        SFL_DBG("Sending pong.");
         sendPong(from, fromlen, tid);
         break;
     case MessageType::FindNode:
-        DEBUG("Got \"find node\" request");
+        SFL_DBG("Got \"find node\" request");
         newNode(id, from, fromlen, 1);
-        DEBUG("Sending closest nodes (%d).", want);
+        SFL_DBG("Sending closest nodes (%d).", want);
         sendClosestNodes(from, fromlen, tid, target, want);
         break;
     case MessageType::GetValues:
-        DEBUG("Got \"get values\" request");
+        SFL_DBG("Got \"get values\" request");
         newNode(id, from, fromlen, 1);
         if (info_hash == zeroes) {
-            DEBUG("Eek!  Got get_values with no info_hash.");
+            SFL_DBG("Eek!  Got get_values with no info_hash.");
             sendError(from, fromlen, tid, 203, "Get_values with no info_hash");
             break;
         } else {
             Storage* st = findStorage(info_hash);
             Blob ntoken = makeToken(from, false);
             if (st && st->values.size() > 0) {
-                 DEBUG("Sending found%s values.", from->sa_family == AF_INET6 ? " IPv6" : "");
+                 SFL_DBG("Sending found%s values.", from->sa_family == AF_INET6 ? " IPv6" : "");
                  sendClosestNodes(from, fromlen, tid, info_hash, want, ntoken, st);
             } else {
-                DEBUG("Sending nodes for get_values.");
+                SFL_DBG("Sending nodes for get_values.");
                 sendClosestNodes(from, fromlen, tid, info_hash, want, ntoken);
             }
         }
         break;
     case MessageType::AnnounceValue:
-        DEBUG("Got \"announce value\" request!");
+        SFL_DBG("Got \"announce value\" request!");
         newNode(id, from, fromlen, 1);
         if (info_hash == zeroes) {
-            DEBUG("Announce_value with no info_hash.");
+            SFL_DBG("Announce_value with no info_hash.");
             sendError(from, fromlen, tid, 203, "Announce_value with no info_hash");
             break;
         }
         if (!tokenMatch(token, from)) {
-            DEBUG("Incorrect token %s for announce_values.", to_hex(token.data(), token.size()).c_str());
+            SFL_DBG("Incorrect token %s for announce_values.", to_hex(token.data(), token.size()).c_str());
             sendError(from, fromlen, tid, 401, "Announce_value with wrong token");
             break;
         }
         for (const auto& v : values) {
             if (v->id == Value::INVALID_ID) {
-                DEBUG("Incorrect value id ");
+                SFL_DBG("Incorrect value id ");
                 sendError(from, fromlen, tid, 203, "Announce_value with invalid id");
                 continue;
             }
             auto lv = getLocal(info_hash, v->id);
             if (lv && lv->owner != id) {
-                DEBUG("Attempting to store value belonging to another user.");
+                SFL_DBG("Attempting to store value belonging to another user.");
                 sendError(from, fromlen, tid, 203, "Announce_value with wrong permission");
                 continue;
             }
@@ -1731,7 +1731,7 @@ Dht::processMessage(const uint8_t *buf, size_t buflen, const sockaddr *from, soc
                 // Allow the value to be edited by the storage policy
                 std::shared_ptr<Value> vc = v;
                 const auto& type = getType(vc->type);
-                DEBUG("Found value of type %s", type.name.c_str());
+                SFL_DBG("Found value of type %s", type.name.c_str());
                 if (type.storePolicy(vc, id, from, fromlen)) {
                     storageStore(info_hash, vc);
                 }
@@ -1740,7 +1740,7 @@ Dht::processMessage(const uint8_t *buf, size_t buflen, const sockaddr *from, soc
             /* Note that if storage_store failed, we lie to the requestor.
                This is to prevent them from backtracking, and hence
                polluting the DHT. */
-            DEBUG("Sending announceValue confirmation.");
+            SFL_DBG("Sending announceValue confirmation.");
             sendValueAnnounced(from, fromlen, tid, v->id);
         }
     }
@@ -1766,7 +1766,7 @@ Dht::periodic(const uint8_t *buf, size_t buflen,
     }
 
     if (search_time > 0 && now.tv_sec >= search_time) {
-        DEBUG("search_time");
+        SFL_DBG("search_time");
         search_time = 0;
         for (auto& sr : searches) {
             time_t tm = sr.getNextStepTime(types, now.tv_sec);
@@ -1779,22 +1779,22 @@ Dht::periodic(const uint8_t *buf, size_t buflen,
                 search_time = tm;
         }
         if (search_time == 0)
-            DEBUG("next search_time : (none)");
+            SFL_DBG("next search_time : (none)");
         else if (search_time < now.tv_sec)
-            DEBUG("next search_time : %lu (ASAP)");
+            SFL_DBG("next search_time : %lu (ASAP)");
         else
-            DEBUG("next search_time : %lu (in %lu s)", search_time, search_time-now.tv_sec);
+            SFL_DBG("next search_time : %lu (in %lu s)", search_time, search_time-now.tv_sec);
     }
 
     if (now.tv_sec >= confirm_nodes_time) {
-        //DEBUG("confirm_nodes_time");
+        //SFL_DBG("confirm_nodes_time");
         bool soon = false;
 
         soon |= bucketMaintenance(buckets);
         soon |= bucketMaintenance(buckets6);
 
         if (!soon) {
-//            DEBUG("!soon");
+//            SFL_DBG("!soon");
             if (mybucket_grow_time >= now.tv_sec - 150)
                 soon |= neighbourhoodMaintenance(buckets);
             if (mybucket6_grow_time >= now.tv_sec - 150)
@@ -1863,14 +1863,14 @@ Dht::importValues(const std::vector<ValuesExport>& import)
                     val_time = deserialize<time_t>(b, e);
                     tmp_val.unpack(b, e);
                 } catch (const std::exception&) {
-                    ERROR("Error reading value at %s", h.first.toString().c_str());
+                    SFL_ERR("Error reading value at %s", h.first.toString().c_str());
                     continue;
                 }
                 auto st = storageStore(h.first, std::make_shared<Value>(std::move(tmp_val)));
                 st->time = val_time;
             }
         } catch (const std::exception&) {
-            ERROR("Error reading values at %s", h.first.toString().c_str());
+            SFL_ERR("Error reading values at %s", h.first.toString().c_str());
             continue;
         }
     }
@@ -1922,7 +1922,7 @@ Dht::insertNode(const InfoHash& id, const sockaddr *sa, socklen_t salen)
 int
 Dht::pingNode(const sockaddr *sa, socklen_t salen)
 {
-    DEBUG("Sending ping.");
+    SFL_DBG("Sending ping.");
     return sendPing(sa, salen, TransId {TransPrefix::PING});
 }
 
@@ -1954,7 +1954,7 @@ Dht::send(const void *buf, size_t len, int flags, const sockaddr *sa, socklen_t
         abort();
 
     if (isNodeBlacklisted(sa, salen)) {
-        DEBUG("Attempting to send to blacklisted node.");
+        SFL_DBG("Attempting to send to blacklisted node.");
         errno = EPERM;
         return -1;
     }
@@ -2172,7 +2172,7 @@ Dht::sendClosestNodes(const sockaddr *sa, socklen_t salen, TransId tid,
                 numnodes6 = bufferClosestNodes(nodes6, numnodes6, id, *std::prev(b));
         }
     }
-    DEBUG("sending closest nodes (%d+%d nodes.)", numnodes, numnodes6);
+    SFL_DBG("sending closest nodes (%d+%d nodes.)", numnodes, numnodes6);
 
     try {
         return sendNodesValues(sa, salen, tid,
@@ -2180,7 +2180,7 @@ Dht::sendClosestNodes(const sockaddr *sa, socklen_t salen, TransId tid,
                                 nodes6, numnodes6 * 38,
                                 st, token);
     } catch (const std::overflow_error& e) {
-        ERROR("Can't send value: buffer not large enough !");
+        SFL_ERR("Can't send value: buffer not large enough !");
         return -1;
     }
 }
@@ -2402,7 +2402,7 @@ Dht::parseMessage(const uint8_t *buf, size_t buflen,
                 break;
         }
         if (i >= buflen || buf[i] != 'e')
-            DEBUG("eek... unexpected end for values.");
+            SFL_DBG("eek... unexpected end for values.");
     }
 
     p = (uint8_t*)dht_memmem(buf, buflen, "3:vid8:", 7);
@@ -2426,11 +2426,11 @@ Dht::parseMessage(const uint8_t *buf, size_t buflen,
                 else if (buf[i] == '2' && memcmp(buf + i + 2, "n6", 2) == 0)
                     *want_return |= WANT6;
                 else
-                    DEBUG("eek... unexpected want flag (%c)", buf[i]);
+                    SFL_DBG("eek... unexpected want flag (%c)", buf[i]);
                 i += 2 + buf[i] - '0';
             }
             if (i >= buflen || buf[i] != 'e')
-                DEBUG("eek... unexpected end for want.");
+                SFL_DBG("eek... unexpected end for want.");
         } else {
             *want_return = -1;
         }
diff --git a/daemon/src/dht/dhtcpp/securedht.cpp b/daemon/src/dht/dhtcpp/securedht.cpp
index 627a94f57bc359074260980d84421360558aa21b..f83f6ea25625c0c2e6a66970e496d036752e0ee0 100644
--- a/daemon/src/dht/dhtcpp/securedht.cpp
+++ b/daemon/src/dht/dhtcpp/securedht.cpp
@@ -74,11 +74,11 @@ SecureDht::SecureDht(int s, int s6, crypto::Identity id)
         return;
     int rc = gnutls_global_init();
     if (rc != GNUTLS_E_SUCCESS) {
-        ERROR("Error initializing GnuTLS : %s", gnutls_strerror(rc));
+        SFL_ERR("Error initializing GnuTLS : %s", gnutls_strerror(rc));
         throw DhtException("Error initializing GnuTLS");
     }
     if (certificate_->getPublicKey().getId() != key_->getPublicKey().getId()) {
-        ERROR("SecureDht: provided certificate doesn't match private key.");
+        SFL_ERR("SecureDht: provided certificate doesn't match private key.");
     }
     Dht::registerType(crypto::CERTIFICATE);
     Value cert_val {
@@ -88,9 +88,9 @@ SecureDht::SecureDht(int s, int s6, crypto::Identity id)
     cert_val.owner = getId();
     Dht::put(getId(), std::move(cert_val), [](bool ok) {
         if (ok)
-            DEBUG("SecureDht: public key announced successfully");
+            SFL_DBG("SecureDht: public key announced successfully");
         else
-            ERROR("SecureDht: error while announcing public key!");
+            SFL_ERR("SecureDht: error while announcing public key!");
     });
 }
 
@@ -202,7 +202,7 @@ SecureDht::get(const InfoHash& id, GetCallback cb, DoneCallback donecb, Value::F
                     Value decrypted_val { v->id };
                     decrypted_val.unpackBlob(decrypted_data);
                 } catch (const std::exception& e) {
-                    WARN("Could not decrypt value %s at infohash %s", v->toString().c_str(), id.toString().c_str());
+                    SFL_WARN("Could not decrypt value %s at infohash %s", v->toString().c_str(), id.toString().c_str());
                     continue;
                 }
                 auto dv = std::make_shared<Value>(std::move(decrypted_val));
diff --git a/daemon/src/dht/dhtcpp/value.cpp b/daemon/src/dht/dhtcpp/value.cpp
index 74fd8585424675a486aa0e3a09c33947d8226e00..06a5f5b3f8108520784dc16c0c2711e66ede57a9 100644
--- a/daemon/src/dht/dhtcpp/value.cpp
+++ b/daemon/src/dht/dhtcpp/value.cpp
@@ -62,18 +62,18 @@ const ValueType ValueType::USER_DATA = {0, "User Data"};
 bool
 ServiceAnnouncement::storePolicy(std::shared_ptr<Value>& v, InfoHash, const sockaddr* from, socklen_t fromlen)
 {
-    WARN("ServiceAnnouncement::storePolicy %s", v->toString().c_str());
+    SFL_WARN("ServiceAnnouncement::storePolicy %s", v->toString().c_str());
     ServiceAnnouncement request {};
     request.unpackBlob(v->data);
     if (request.getPort() == 0) {
-        ERROR("Announce_values with forbidden port %d.", request.getPort());
+        SFL_ERR("Announce_values with forbidden port %d.", request.getPort());
         return false;
     }
     ServiceAnnouncement sa_addr {from, fromlen};
     sa_addr.setPort(request.getPort());
     // argument v is modified (not the value).
     v = std::make_shared<Value>(ServiceAnnouncement::TYPE, sa_addr, v->id);
-    WARN("ServiceAnnouncement::storePolicy ->  %s", v->toString().c_str());
+    SFL_WARN("ServiceAnnouncement::storePolicy ->  %s", v->toString().c_str());
     return true;
 }
 
@@ -200,4 +200,4 @@ ServiceAnnouncement::unpack(Blob::const_iterator& begin, Blob::const_iterator& e
 }
 
 
-}
\ No newline at end of file
+}
diff --git a/daemon/src/fileutils.cpp b/daemon/src/fileutils.cpp
index b1c2f382b35db24d433bcaa3c2f52120bd7c84bb..a68c4079c99e8c33688b48943dbc34e8ef10d1f2 100644
--- a/daemon/src/fileutils.cpp
+++ b/daemon/src/fileutils.cpp
@@ -127,23 +127,23 @@ create_pidfile()
     char buf[100];
     f.fd = open(f.name.c_str(), O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
     if (f.fd == -1) {
-        ERROR("Could not open PID file %s", f.name.c_str());
+        SFL_ERR("Could not open PID file %s", f.name.c_str());
         return f;
     }
 
     if (lockRegion(f.fd, F_WRLCK, SEEK_SET, 0, 0) == -1) {
         if (errno  == EAGAIN or errno == EACCES)
-            ERROR("PID file '%s' is locked; probably "
+            SFL_ERR("PID file '%s' is locked; probably "
                     "'%s' is already running", f.name.c_str(), PACKAGE_NAME);
         else
-            ERROR("Unable to lock PID file '%s'", f.name.c_str());
+            SFL_ERR("Unable to lock PID file '%s'", f.name.c_str());
         close(f.fd);
         f.fd = -1;
         return f;
     }
 
     if (ftruncate(f.fd, 0) == -1) {
-        ERROR("Could not truncate PID file '%s'", f.name.c_str());
+        SFL_ERR("Could not truncate PID file '%s'", f.name.c_str());
         close(f.fd);
         f.fd = -1;
         return f;
@@ -153,7 +153,7 @@ create_pidfile()
 
     const int buf_strlen = strlen(buf);
     if (write(f.fd, buf, buf_strlen) != buf_strlen) {
-        ERROR("Problem writing to PID file '%s'", f.name.c_str());
+        SFL_ERR("Problem writing to PID file '%s'", f.name.c_str());
         close(f.fd);
         f.fd = -1;
         return f;
@@ -166,7 +166,10 @@ std::string
 expand_path(const std::string &path)
 {
 #ifdef __ANDROID__
-    ERROR("Path expansion not implemented, returning original");
+    SFL_ERR("Path expansion not implemented, returning original");
+    return path;
+#elif _WIN32
+	SFL_ERR("Path expansion not implemented, returning original");
     return path;
 #else
 
@@ -177,20 +180,20 @@ expand_path(const std::string &path)
 
     switch (ret) {
         case WRDE_BADCHAR:
-            ERROR("Illegal occurrence of newline or one of |, &, ;, <, >, "
+            SFL_ERR("Illegal occurrence of newline or one of |, &, ;, <, >, "
                   "(, ), {, }.");
             return result;
         case WRDE_BADVAL:
-            ERROR("An undefined shell variable was referenced");
+            SFL_ERR("An undefined shell variable was referenced");
             return result;
         case WRDE_CMDSUB:
-            ERROR("Command substitution occurred");
+            SFL_ERR("Command substitution occurred");
             return result;
         case WRDE_SYNTAX:
-            ERROR("Shell syntax error");
+            SFL_ERR("Shell syntax error");
             return result;
         case WRDE_NOSPACE:
-            ERROR("Out of memory.");
+            SFL_ERR("Out of memory.");
             // This is the only error where we must call wordfree
             break;
         default:
@@ -219,7 +222,7 @@ FileHandle::~FileHandle()
     if (fd != -1) {
         close(fd);
         if (unlink(name.c_str()) == -1)
-            ERROR("%s", strerror(errno));
+            SFL_ERR("%s", strerror(errno));
     }
 }
 
diff --git a/daemon/src/history/history.cpp b/daemon/src/history/history.cpp
index f4f1e2fd8aab5f8fbc9649972b6d7f4179502d47..a35dd67ff9d4056aaa512e02b0b51a0a26aa661d 100644
--- a/daemon/src/history/history.cpp
+++ b/daemon/src/history/history.cpp
@@ -59,7 +59,7 @@ bool History::load(int limit)
     ensurePath();
     std::ifstream infile(path_.c_str());
     if (!infile) {
-        DEBUG("No history file to load");
+        SFL_DBG("No history file to load");
         return false;
     }
 
@@ -74,7 +74,7 @@ bool History::load(int limit)
 bool History::save()
 {
     std::lock_guard<std::mutex> lock(historyItemsMutex_);
-    DEBUG("Saving history in XDG directory: %s", path_.c_str());
+    SFL_DBG("Saving history in XDG directory: %s", path_.c_str());
     ensurePath();
     std::sort(items_.begin(), items_.end());
     std::ofstream outfile(path_.c_str());
@@ -110,7 +110,7 @@ void History::ensurePath()
         if (mkdir(userdata.data(), 0755) != 0) {
             // If directory creation failed
             if (errno != EEXIST) {
-                DEBUG("Cannot create directory: %s", userdata.c_str());
+                SFL_DBG("Cannot create directory: %s", userdata.c_str());
                 strErr();
                 return;
             }
@@ -139,7 +139,7 @@ void History::setPath(const std::string &path)
 void History::addCall(Call *call, int limit)
 {
     if (!call) {
-        ERROR("Call is NULL, ignoring");
+        SFL_ERR("Call is NULL, ignoring");
         return;
     }
     call->time_stop();
diff --git a/daemon/src/iax/iaxaccount.cpp b/daemon/src/iax/iaxaccount.cpp
index a753da0063c1c5447131d606decce4a3f297f6eb..f9d85af99bd85df6178f209a91d128773306125d 100644
--- a/daemon/src/iax/iaxaccount.cpp
+++ b/daemon/src/iax/iaxaccount.cpp
@@ -97,7 +97,7 @@ void IAXAccount::doRegister()
         link_->init();
         sendRegister();
     } catch (const VoipLinkException &e) {
-        ERROR("IAXAccount: %s", e.what());
+        SFL_ERR("IAXAccount: %s", e.what());
     }
 }
 
@@ -108,7 +108,7 @@ IAXAccount::doUnregister(std::function<void(bool)> cb)
         sendUnregister();
         link_->terminate();
     } catch (const VoipLinkException &e) {
-        ERROR("IAXAccount: %s", e.what());
+        SFL_ERR("IAXAccount: %s", e.what());
     }
     if (cb)
         cb(true);
@@ -176,7 +176,7 @@ void
 IAXAccount::sendRegister()
 {
     if (not isEnabled()) {
-        WARN("Account must be enabled to register, ignoring");
+        SFL_WARN("Account must be enabled to register, ignoring");
         return;
     }
 
@@ -194,7 +194,7 @@ IAXAccount::sendRegister()
     if (regSession_) {
         {
             std::lock_guard<std::mutex> lock(IAXVoIPLink::mutexIAX);
-            DEBUG("register IAXAccount %s", getHostname().c_str());
+            SFL_DBG("register IAXAccount %s", getHostname().c_str());
             iax_register(regSession_.get(), getHostname().data(),
                          getUsername().data(), getPassword().data(), 120);
         }
@@ -207,7 +207,7 @@ IAXAccount::sendRegister()
 void
 IAXAccount::sendUnregister(std::function<void(bool)> cb)
 {
-    DEBUG("unregister IAXAccount %s", getHostname().c_str());
+    SFL_DBG("unregister IAXAccount %s", getHostname().c_str());
     destroyRegSession();
 
     nextRefreshStamp_ = 0;
diff --git a/daemon/src/iax/iaxcall.cpp b/daemon/src/iax/iaxcall.cpp
index b3a6f8c801dce096229553c2fbf96c0c5232dddb..2a4f56c67d3166d96a0cc446ccc8fe93c3477261 100644
--- a/daemon/src/iax/iaxcall.cpp
+++ b/daemon/src/iax/iaxcall.cpp
@@ -66,7 +66,7 @@ codecToASTFormat(int c)
             return AST_FORMAT_SPEEX;
 
         default:
-            ERROR("Codec %d not supported!", c);
+            SFL_ERR("Codec %d not supported!", c);
             return 0;
     }
 }
@@ -92,7 +92,7 @@ int IAXCall::getSupportedFormat(const std::string &accountID) const
         for (const auto &i : codecs)
             format_mask |= codecToASTFormat(i);
     } else
-        ERROR("No IAx account could be found");
+        SFL_ERR("No IAx account could be found");
 
     return format_mask;
 }
@@ -113,7 +113,7 @@ int IAXCall::getFirstMatchingFormat(int needles, const std::string &accountID) c
                 return format_mask;
         }
     } else
-        ERROR("No IAx account could be found");
+        SFL_ERR("No IAx account could be found");
 
     return 0;
 }
@@ -132,7 +132,7 @@ int IAXCall::getAudioCodec() const
         case AST_FORMAT_SPEEX:
             return PAYLOAD_CODEC_SPEEX_8000;
         default:
-            ERROR("IAX: Format %d not supported!", format);
+            SFL_ERR("IAX: Format %d not supported!", format);
             return -1;
     }
 }
diff --git a/daemon/src/iax/iaxvoiplink.cpp b/daemon/src/iax/iaxvoiplink.cpp
index 95fdc50806728314d0031ee0d8f9b29513ed98cc..b39b6b8904777f88fd3802de0f5bca50b6a650d4 100644
--- a/daemon/src/iax/iaxvoiplink.cpp
+++ b/daemon/src/iax/iaxvoiplink.cpp
@@ -197,7 +197,7 @@ IAXVoIPLink::sendAudioFromMic()
             std::lock_guard<std::mutex> lock(mutexIAX);
 
             if (iax_send_voice(currentCall->session, currentCall->format, encodedData_, compSize, outSamples) == -1)
-                ERROR("IAX: Error sending voice data.");
+                SFL_ERR("IAX: Error sending voice data.");
         }
     }
 }
@@ -206,7 +206,7 @@ void
 IAXVoIPLink::handleReject(IAXCall& call)
 {
     call.setConnectionState(Call::CONNECTED);
-    call.setState(Call::ERROR);
+    call.setState(Call::MERROR);
     Manager::instance().callFailure(call.getCallId());
     call.removeCall();
 }
@@ -392,7 +392,7 @@ void IAXVoIPLink::iaxHandlePrecallEvent(iax_event* event)
 
             call = account_.newIncomingCall<IAXCall>(id);
             if (!call) {
-                ERROR("failed to create an incoming IAXCall from account %s",
+                SFL_ERR("failed to create an incoming IAXCall from account %s",
                       accountID.c_str());
                 return;
             }
diff --git a/daemon/src/im/instant_messaging.cpp b/daemon/src/im/instant_messaging.cpp
index 534a2b87475829caafc117fe9052a09087721101..6262db73ad0678f08d300336852c43d41c06b007 100644
--- a/daemon/src/im/instant_messaging.cpp
+++ b/daemon/src/im/instant_messaging.cpp
@@ -151,7 +151,7 @@ InstantMessaging::parseXmlUriList(const std::string &urilist)
     XML_SetElementHandler(parser, startElementCallback, endElementCallback);
 
     if (XML_Parse(parser, urilist.c_str(), urilist.size(), 1) == XML_STATUS_ERROR) {
-        ERROR("%s at line %lu\n", XML_ErrorString(XML_GetErrorCode(parser)),
+        SFL_ERR("%s at line %lu\n", XML_ErrorString(XML_GetErrorCode(parser)),
                XML_GetCurrentLineNumber(parser));
         throw InstantMessageException("Error while parsing uri-list xml content");
     }
diff --git a/daemon/src/ip_utils.cpp b/daemon/src/ip_utils.cpp
index 73a34fead112d3d6936d0194308456ad67ca5fa6..761cf64a221d2b60d14f0dfb6ad5251ede6dada8 100644
--- a/daemon/src/ip_utils.cpp
+++ b/daemon/src/ip_utils.cpp
@@ -59,7 +59,7 @@ ip_utils::getAddrList(const std::string &name, pj_uint16_t family)
     pj_cstr(&pjname, name.c_str());
     auto status = pj_getaddrinfo(family, &pjname, &addr_num, res);
     if (status != PJ_SUCCESS) {
-        ERROR("Error resolving %s :", name.c_str());
+        SFL_ERR("Error resolving %s :", name.c_str());
         sip_utils::sip_strerror(status);
         return ipList;
     }
@@ -118,12 +118,12 @@ ip_utils::getLocalAddr(pj_uint16_t family)
         return ip_addr;
     }
 #if HAVE_IPV6
-    WARN("Could not get preferred address familly (%s)", (family == pj_AF_INET6()) ? "IPv6" : "IPv4");
+    SFL_WARN("Could not get preferred address familly (%s)", (family == pj_AF_INET6()) ? "IPv6" : "IPv4");
     family = (family == pj_AF_INET()) ? pj_AF_INET6() : pj_AF_INET();
     status = pj_gethostip(family, ip_addr);
     if (status == PJ_SUCCESS) return ip_addr;
 #endif
-    ERROR("Could not get local IP");
+    SFL_ERR("Could not get local IP");
     return ip_addr;
 }
 
@@ -138,19 +138,26 @@ ip_utils::getInterfaceAddr(const std::string &interface, pj_uint16_t family)
 
     int fd = socket(unix_family, SOCK_DGRAM, 0);
     if (fd < 0) {
-        ERROR("Could not open socket: %m");
+        SFL_ERR("Could not open socket: %m");
         return addr;
     }
 
     if (unix_family == AF_INET6) {
         int val = family != pj_AF_UNSPEC();
-        if (setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, (void *) &val, sizeof(val)) < 0) {
-            ERROR("Could not setsockopt: %m");
+#ifdef _WIN32
+		char* valPtr = (char *) &val;
+#else
+		void* valPtr = (void *) &val;
+#endif
+        if (setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, valPtr, sizeof(val)) < 0) {
+            SFL_ERR("Could not setsockopt: %m");
             close(fd);
             return addr;
         }
     }
 
+#ifdef _WIN32 /* TODO: WINDOWS, implement address info. */
+#else
     ifreq ifr;
     strncpy(ifr.ifr_name, interface.c_str(), sizeof ifr.ifr_name);
     // guarantee that ifr_name is NULL-terminated
@@ -165,7 +172,7 @@ ip_utils::getInterfaceAddr(const std::string &interface, pj_uint16_t family)
     addr = ifr.ifr_addr;
     if (addr.isUnspecified())
         return getLocalAddr(addr.getFamily());
-
+#endif
     return addr;
 }
 
diff --git a/daemon/src/logger.c b/daemon/src/logger.c
index c885410ff955a97835b11747a80049c22a03b63c..95eb81528ae6a3aea255361d907888b072e7e45c 100644
--- a/daemon/src/logger.c
+++ b/daemon/src/logger.c
@@ -89,7 +89,7 @@ int getDebugMode(void)
 void strErr(void)
 {
 #ifdef __GLIBC__
-    ERROR("%m");
+    SFL_ERR("%m");
 #else
     char buf[1000];
     const char *errstr;
@@ -106,6 +106,6 @@ void strErr(void)
             break;
     }
 
-    ERROR("%s", errstr);
+    SFL_ERR("%s", errstr);
 #endif
 }
diff --git a/daemon/src/logger.h b/daemon/src/logger.h
index 3b1f04f0e5b3e2cb61ac7abd8bf2da0e07b18f63..b3d13532bb3837b7e2ead70ae158f92582ccc8e9 100644
--- a/daemon/src/logger.h
+++ b/daemon/src/logger.h
@@ -87,7 +87,17 @@ void strErr();
 
 #define LOGGER(M, LEVEL, ...) __android_log_print(LEVEL, APP_NAME, \
                                                   LOG_FORMAT(M, ##__VA_ARGS__))
-#else /* __ANDROID__ */
+
+/* TODO: WINDOWS, Actually implement logging system. */
+#elif defined _WIN32
+#define LOG_ERR     0
+#define LOG_WARNING 1
+#define LOG_INFO    2
+#define LOG_DEBUG   3
+
+#define LOGGER(M, LEVEL, ...) printf(M, ##__VA_ARGS__)
+
+#else
 
 #include <syslog.h>
 
@@ -95,12 +105,12 @@ void strErr();
 
 #define LOGGER(M, LEVEL, ...) logger(LEVEL, LOG_FORMAT(M, ##__VA_ARGS__))
 
-#endif /* __ANDROID__ */
+#endif /* __ANDROID__ _WIN32 */
 
-#define ERROR(M, ...)   LOGGER(M, LOG_ERR, ##__VA_ARGS__)
-#define WARN(M, ...)    LOGGER(M, LOG_WARNING, ##__VA_ARGS__)
-#define INFO(M, ...)    LOGGER(M, LOG_INFO, ##__VA_ARGS__)
-#define DEBUG(M, ...)   LOGGER(M, LOG_DEBUG, ##__VA_ARGS__)
+#define SFL_ERR(M, ...)   LOGGER(M, LOG_ERR, ##__VA_ARGS__)
+#define SFL_WARN(M, ...)    LOGGER(M, LOG_WARNING, ##__VA_ARGS__)
+#define SFL_INFO(M, ...)    LOGGER(M, LOG_INFO, ##__VA_ARGS__)
+#define SFL_DBG(M, ...)   LOGGER(M, LOG_DEBUG, ##__VA_ARGS__)
 
 
 #define BLACK "\033[22;30m"
diff --git a/daemon/src/manager.cpp b/daemon/src/manager.cpp
index cced0b6d50461549e2d4cbd404c4ed8290138b5d..18ce2177da129cf365ab99bcef8996309d902385 100644
--- a/daemon/src/manager.cpp
+++ b/daemon/src/manager.cpp
@@ -39,7 +39,7 @@ ManagerImpl& Manager::instance()
     // This will give a warning that can be ignored the first time instance()
     // is called...subsequent warnings are more serious
     if (not ManagerImpl::initialized)
-        WARN("Not initialized");
+        SFL_WARN("Not initialized");
 
     return instance_;
 }
diff --git a/daemon/src/managerimpl.cpp b/daemon/src/managerimpl.cpp
index 617a5682a03dad58ca84c9afdadab8e0f47ccce5..c40b5d8533bad11af32ef41d27ced14cbddcc48e 100644
--- a/daemon/src/managerimpl.cpp
+++ b/daemon/src/managerimpl.cpp
@@ -153,11 +153,11 @@ ManagerImpl::parseConfiguration()
         const int error_count = loadAccountMap(parsedFile);
 
         if (error_count > 0) {
-            WARN("Errors while parsing %s", path_.c_str());
+            SFL_WARN("Errors while parsing %s", path_.c_str());
             result = false;
         }
     } catch (const YAML::BadFile &e) {
-        WARN("Could not open config file: creating default account map");
+        SFL_WARN("Could not open config file: creating default account map");
         loadDefaultAccountMap();
     }
 
@@ -171,7 +171,7 @@ ManagerImpl::init(const std::string &config_file)
     initialized = true;
 
     path_ = config_file.empty() ? retrieveConfigPath() : config_file;
-    DEBUG("Configuration file path: %s", path_.c_str());
+    SFL_DBG("Configuration file path: %s", path_.c_str());
 
     bool no_errors = true;
 
@@ -181,7 +181,7 @@ ManagerImpl::init(const std::string &config_file)
     try {
         no_errors = parseConfiguration();
     } catch (const YAML::Exception &e) {
-        ERROR("%s", e.what());
+        SFL_ERR("%s", e.what());
         no_errors = false;
     }
 
@@ -190,7 +190,7 @@ ManagerImpl::init(const std::string &config_file)
         make_backup(path_);
     } else {
         // restore previous configuration
-        WARN("Restoring last working configuration");
+        SFL_WARN("Restoring last working configuration");
 
         try {
             // remove accounts from broken configuration
@@ -198,8 +198,8 @@ ManagerImpl::init(const std::string &config_file)
             restore_backup(path_);
             parseConfiguration();
         } catch (const YAML::Exception &e) {
-            ERROR("%s", e.what());
-            WARN("Restoring backup failed, creating default account map");
+            SFL_ERR("%s", e.what());
+            SFL_WARN("Restoring backup failed, creating default account map");
             loadDefaultAccountMap();
         }
     }
@@ -241,7 +241,7 @@ ManagerImpl::finish()
         callFactory.forbid();
 
         // Hangup all remaining active calls
-        DEBUG("Hangup %zu remaining call(s)", callFactory.callCount());
+        SFL_DBG("Hangup %zu remaining call(s)", callFactory.callCount());
         for (const auto call : callFactory.getAllCalls())
             hangupCall(call->getCallId());
         callFactory.clear();
@@ -260,7 +260,7 @@ ManagerImpl::finish()
             audiodriver_.reset();
         }
     } catch (const VoipLinkException &err) {
-        ERROR("%s", err.what());
+        SFL_ERR("%s", err.what());
     }
 }
 
@@ -305,7 +305,7 @@ void
 ManagerImpl::switchCall(std::shared_ptr<Call> call)
 {
     std::lock_guard<std::mutex> m(currentCallMutex_);
-    DEBUG("----- Switch current call id to '%s' -----",
+    SFL_DBG("----- Switch current call id to '%s' -----",
           call ? call->getCallId().c_str() : "<nullptr>");
     currentCall_ = call;
 }
@@ -322,17 +322,17 @@ ManagerImpl::outgoingCall(const std::string& preferred_account_id,
                           const std::string& conf_id)
 {
     if (call_id.empty()) {
-        DEBUG("New outgoing call abort, missing callid");
+        SFL_DBG("New outgoing call abort, missing callid");
         return false;
     }
 
     // Call ID must be unique
     if (isValidCall(call_id)) {
-        ERROR("Call id already exists in outgoing call");
+        SFL_ERR("Call id already exists in outgoing call");
         return false;
     }
 
-    DEBUG("New outgoing call %s to %s", call_id.c_str(), to.c_str());
+    SFL_DBG("New outgoing call %s to %s", call_id.c_str(), to.c_str());
 
     stopTone();
 
@@ -344,7 +344,7 @@ ManagerImpl::outgoingCall(const std::string& preferred_account_id,
 
     // in any cases we have to detach from current communication
     if (hasCurrentCall()) {
-        DEBUG("Has current call (%s) put it onhold", current_call_id.c_str());
+        SFL_DBG("Has current call (%s) put it onhold", current_call_id.c_str());
 
         // if this is not a conference and this and is not a conference participant
         if (not isConference(current_call_id) and not isConferenceParticipant(current_call_id))
@@ -354,10 +354,10 @@ ManagerImpl::outgoingCall(const std::string& preferred_account_id,
     }
 
     try {
-        /* WARN: after this call the account_id is obsolete
+        /* SFL_WARN: after this call the account_id is obsolete
          * as the factory may decide to use another account (like IP2IP).
          */
-        DEBUG("New outgoing call to %s", to_cleaned.c_str());
+        SFL_DBG("New outgoing call to %s", to_cleaned.c_str());
         auto call = newOutgoingCall(call_id, to_cleaned, preferred_account_id);
 
         // try to reverse match the peer name using the cache
@@ -372,11 +372,11 @@ ManagerImpl::outgoingCall(const std::string& preferred_account_id,
         call->setConfId(conf_id);
     } catch (const VoipLinkException &e) {
         callFailure(call_id);
-        ERROR("%s", e.what());
+        SFL_ERR("%s", e.what());
         return false;
     } catch (ost::Socket *) {
         callFailure(call_id);
-        ERROR("Could not bind socket");
+        SFL_ERR("Could not bind socket");
         return false;
     }
 
@@ -391,7 +391,7 @@ ManagerImpl::answerCall(const std::string& call_id)
 
     auto call = getCallFromCallID(call_id);
     if (!call) {
-        ERROR("Call %s is NULL", call_id.c_str());
+        SFL_ERR("Call %s is NULL", call_id.c_str());
         return false;
     }
 
@@ -404,14 +404,14 @@ ManagerImpl::answerCall(const std::string& call_id)
     // in any cases we have to detach from current communication
     if (hasCurrentCall()) {
 
-        DEBUG("Currently conversing with %s", current_call_id.c_str());
+        SFL_DBG("Currently conversing with %s", current_call_id.c_str());
 
         if (not isConference(current_call_id) and not isConferenceParticipant(current_call_id)) {
-            DEBUG("Answer call: Put the current call (%s) on hold", current_call_id.c_str());
+            SFL_DBG("Answer call: Put the current call (%s) on hold", current_call_id.c_str());
             onHoldCall(current_call_id);
         } else if (isConference(current_call_id) and not isConferenceParticipant(call_id)) {
             // if we are talking to a conference and we are answering an incoming call
-            DEBUG("Detach main participant from conference");
+            SFL_DBG("Detach main participant from conference");
             detachParticipant(sfl::RingBufferPool::DEFAULT_ID);
         }
     }
@@ -419,7 +419,7 @@ ManagerImpl::answerCall(const std::string& call_id)
     try {
         call->answer();
     } catch (const std::runtime_error &e) {
-        ERROR("%s", e.what());
+        SFL_ERR("%s", e.what());
         result = false;
     }
 
@@ -463,13 +463,13 @@ ManagerImpl::hangupCall(const std::string& callId)
 
     stopTone();
 
-    DEBUG("Send call state change (HUNGUP) for id %s", callId.c_str());
+    SFL_DBG("Send call state change (HUNGUP) for id %s", callId.c_str());
     client_.getCallManager()->callStateChanged(callId, "HUNGUP");
 
     /* We often get here when the call was hungup before being created */
     auto call = getCallFromCallID(callId);
     if (not call) {
-        WARN("Could not hang up non-existant call %s", callId.c_str());
+        SFL_WARN("Could not hang up non-existant call %s", callId.c_str());
         checkAudio();
         return false;
     }
@@ -491,7 +491,7 @@ ManagerImpl::hangupCall(const std::string& callId)
         checkAudio();
         saveHistory();
     } catch (const VoipLinkException &e) {
-        ERROR("%s", e.what());
+        SFL_ERR("%s", e.what());
         return false;
     }
 
@@ -501,7 +501,7 @@ ManagerImpl::hangupCall(const std::string& callId)
 bool
 ManagerImpl::hangupConference(const std::string& id)
 {
-    DEBUG("Hangup conference %s", id.c_str());
+    SFL_DBG("Hangup conference %s", id.c_str());
 
     ConferenceMap::iterator iter_conf = conferenceMap_.find(id);
 
@@ -514,7 +514,7 @@ ManagerImpl::hangupConference(const std::string& id)
             for (const auto &item : participants)
                 hangupCall(item);
         } else {
-            ERROR("No such conference %s", id.c_str());
+            SFL_ERR("No such conference %s", id.c_str());
             return false;
         }
     }
@@ -538,11 +538,11 @@ ManagerImpl::onHoldCall(const std::string& callId)
         if (auto call = getCallFromCallID(callId)) {
             call->onhold();
         } else {
-            DEBUG("CallID %s doesn't exist in call onHold", callId.c_str());
+            SFL_DBG("CallID %s doesn't exist in call onHold", callId.c_str());
             return false;
         }
     } catch (const VoipLinkException &e) {
-        ERROR("%s", e.what());
+        SFL_ERR("%s", e.what());
         result = false;
     }
 
@@ -575,7 +575,7 @@ ManagerImpl::offHoldCall(const std::string& callId)
     // Place current call on hold if it isn't
     if (hasCurrentCall()) {
         if (not isConference(currentCallId) and not isConferenceParticipant(currentCallId)) {
-            DEBUG("Has current call (%s), put on hold", currentCallId.c_str());
+            SFL_DBG("Has current call (%s), put on hold", currentCallId.c_str());
             onHoldCall(currentCallId);
         } else if (isConference(currentCallId) && callId != currentCallId) {
             holdConference(currentCallId);
@@ -591,7 +591,7 @@ ManagerImpl::offHoldCall(const std::string& callId)
         else
             result = false;
     } catch (const VoipLinkException &e) {
-        ERROR("%s", e.what());
+        SFL_ERR("%s", e.what());
         return false;
     }
 
@@ -681,7 +681,7 @@ ManagerImpl::refuseCall(const std::string& id)
 std::shared_ptr<Conference>
 ManagerImpl::createConference(const std::string& id1, const std::string& id2)
 {
-    DEBUG("Create conference with call %s and %s", id1.c_str(), id2.c_str());
+    SFL_DBG("Create conference with call %s and %s", id1.c_str(), id2.c_str());
 
     auto conf = std::make_shared<Conference>();
 
@@ -699,8 +699,8 @@ ManagerImpl::createConference(const std::string& id1, const std::string& id2)
 void
 ManagerImpl::removeConference(const std::string& conference_id)
 {
-    DEBUG("Remove conference %s", conference_id.c_str());
-    DEBUG("number of participants: %u", conferenceMap_.size());
+    SFL_DBG("Remove conference %s", conference_id.c_str());
+    SFL_DBG("number of participants: %u", conferenceMap_.size());
     ConferenceMap::iterator iter = conferenceMap_.find(conference_id);
 
     std::shared_ptr<Conference> conf;
@@ -709,7 +709,7 @@ ManagerImpl::removeConference(const std::string& conference_id)
         conf = iter->second;
 
     if (not conf) {
-        ERROR("Conference not found");
+        SFL_ERR("Conference not found");
         return;
     }
 
@@ -730,9 +730,9 @@ ManagerImpl::removeConference(const std::string& conference_id)
 
     // Then remove the conference from the conference map
     if (conferenceMap_.erase(conference_id))
-        DEBUG("Conference %s removed successfully", conference_id.c_str());
+        SFL_DBG("Conference %s removed successfully", conference_id.c_str());
     else
-        ERROR("Cannot remove conference: %s", conference_id.c_str());
+        SFL_ERR("Cannot remove conference: %s", conference_id.c_str());
 }
 
 std::shared_ptr<Conference>
@@ -828,17 +828,17 @@ bool
 ManagerImpl::addParticipant(const std::string& callId,
                             const std::string& conferenceId)
 {
-    DEBUG("Add participant %s to %s", callId.c_str(), conferenceId.c_str());
+    SFL_DBG("Add participant %s to %s", callId.c_str(), conferenceId.c_str());
     ConferenceMap::iterator iter = conferenceMap_.find(conferenceId);
 
     if (iter == conferenceMap_.end()) {
-        ERROR("Conference id is not valid");
+        SFL_ERR("Conference id is not valid");
         return false;
     }
 
     auto call = getCallFromCallID(callId);
     if (!call) {
-        ERROR("Call id %s is not valid", callId.c_str());
+        SFL_ERR("Call id %s is not valid", callId.c_str());
         return false;
     }
 
@@ -890,7 +890,7 @@ ManagerImpl::addParticipant(const std::string& callId,
     ParticipantSet participants(conf->getParticipantList());
 
     if (participants.empty())
-        ERROR("Participant list is empty for this conference");
+        SFL_ERR("Participant list is empty for this conference");
 
     // Connect stream
     addStream(callId);
@@ -934,7 +934,7 @@ ManagerImpl::addMainParticipant(const std::string& conference_id)
         else if (conf->getState() == Conference::ACTIVE_DETACHED_REC)
             conf->setState(Conference::ACTIVE_ATTACHED_REC);
         else
-            WARN("Invalid conference state while adding main participant");
+            SFL_WARN("Invalid conference state while adding main participant");
 
         client_.getCallManager()->conferenceChanged(conference_id, conf->getStateStr());
     }
@@ -954,21 +954,21 @@ ManagerImpl::joinParticipant(const std::string& callId1,
                              const std::string& callId2)
 {
     if (callId1 == callId2) {
-        ERROR("Cannot join participant %s to itself", callId1.c_str());
+        SFL_ERR("Cannot join participant %s to itself", callId1.c_str());
         return false;
     }
 
     // Set corresponding conference ids for call 1
     auto call1 = getCallFromCallID(callId1);
     if (!call1) {
-        ERROR("Could not find call %s", callId1.c_str());
+        SFL_ERR("Could not find call %s", callId1.c_str());
         return false;
     }
 
     // Set corresponding conderence details
     auto call2 = getCallFromCallID(callId2);
     if (!call2) {
-        ERROR("Could not find call %s", callId2.c_str());
+        SFL_ERR("Could not find call %s", callId2.c_str());
         return false;
     }
 
@@ -982,7 +982,7 @@ ManagerImpl::joinParticipant(const std::string& callId1,
     std::map<std::string, std::string> call2Details(getCallDetails(callId2));
 
     std::string current_call_id(getCurrentCallId());
-    DEBUG("Current Call ID %s", current_call_id.c_str());
+    SFL_DBG("Current Call ID %s", current_call_id.c_str());
 
     // detach from the conference and switch to this conference
     if ((current_call_id != callId1) and (current_call_id != callId2)) {
@@ -1004,7 +1004,7 @@ ManagerImpl::joinParticipant(const std::string& callId1,
 
     // Process call1 according to its state
     std::string call1_state_str(call1Details.find("CALL_STATE")->second);
-    DEBUG("Process call %s state: %s", callId1.c_str(), call1_state_str.c_str());
+    SFL_DBG("Process call %s state: %s", callId1.c_str(), call1_state_str.c_str());
 
     if (call1_state_str == "HOLD") {
         conf->bindParticipant(callId1);
@@ -1018,11 +1018,11 @@ ManagerImpl::joinParticipant(const std::string& callId1,
         conf->bindParticipant(callId1);
         answerCall(callId1);
     } else
-        WARN("Call state not recognized");
+        SFL_WARN("Call state not recognized");
 
     // Process call2 according to its state
     std::string call2_state_str(call2Details.find("CALL_STATE")->second);
-    DEBUG("Process call %s state: %s", callId2.c_str(), call2_state_str.c_str());
+    SFL_DBG("Process call %s state: %s", callId2.c_str(), call2_state_str.c_str());
 
     if (call2_state_str == "HOLD") {
         conf->bindParticipant(callId2);
@@ -1036,7 +1036,7 @@ ManagerImpl::joinParticipant(const std::string& callId1,
         conf->bindParticipant(callId2);
         answerCall(callId2);
     } else
-        WARN("Call state not recognized");
+        SFL_WARN("Call state not recognized");
 
     // Switch current call id to this conference
     switchCall(getCallFromCallID(conf->getConfID()));
@@ -1053,7 +1053,7 @@ ManagerImpl::createConfFromParticipantList(const std::vector< std::string > &par
 {
     // we must at least have 2 participant for a conference
     if (participantList.size() <= 1) {
-        ERROR("Participant number must be higher or equal to 2");
+        SFL_ERR("Participant number must be higher or equal to 2");
         return;
     }
 
@@ -1101,14 +1101,14 @@ ManagerImpl::detachParticipant(const std::string& call_id)
     if (call_id != sfl::RingBufferPool::DEFAULT_ID) {
         auto call = getCallFromCallID(call_id);
         if (!call) {
-            ERROR("Could not find call %s", call_id.c_str());
+            SFL_ERR("Could not find call %s", call_id.c_str());
             return false;
         }
 
         auto conf = getConferenceFromCallID(call_id);
 
         if (conf == nullptr) {
-            ERROR("Call is not conferencing, cannot detach");
+            SFL_ERR("Call is not conferencing, cannot detach");
             return false;
         }
 
@@ -1116,7 +1116,7 @@ ManagerImpl::detachParticipant(const std::string& call_id)
         std::map<std::string, std::string>::iterator iter_details(call_details.find("CALL_STATE"));
 
         if (iter_details == call_details.end()) {
-            ERROR("Could not find CALL_STATE");
+            SFL_ERR("Could not find CALL_STATE");
             return false;
         }
 
@@ -1127,11 +1127,11 @@ ManagerImpl::detachParticipant(const std::string& call_id)
         removeParticipant(call_id);
 
     } else {
-        DEBUG("Unbind main participant from conference %d");
+        SFL_DBG("Unbind main participant from conference %d");
         getRingBufferPool().unBindAll(sfl::RingBufferPool::DEFAULT_ID);
 
         if (not isConference(current_call_id)) {
-            ERROR("Current call id (%s) is not a conference", current_call_id.c_str());
+            SFL_ERR("Current call id (%s) is not a conference", current_call_id.c_str());
             return false;
         }
 
@@ -1139,7 +1139,7 @@ ManagerImpl::detachParticipant(const std::string& call_id)
 
         auto conf = iter->second;
         if (iter == conferenceMap_.end() or conf == 0) {
-            DEBUG("Conference is NULL");
+            SFL_DBG("Conference is NULL");
             return false;
         }
 
@@ -1148,7 +1148,7 @@ ManagerImpl::detachParticipant(const std::string& call_id)
         else if (conf->getState() == Conference::ACTIVE_ATTACHED_REC)
             conf->setState(Conference::ACTIVE_DETACHED_REC);
         else
-            WARN("Undefined behavior, invalid conference state in detach participant");
+            SFL_WARN("Undefined behavior, invalid conference state in detach participant");
 
         client_.getCallManager()->conferenceChanged(conf->getConfID(),
                                                   conf->getStateStr());
@@ -1162,12 +1162,12 @@ ManagerImpl::detachParticipant(const std::string& call_id)
 void
 ManagerImpl::removeParticipant(const std::string& call_id)
 {
-    DEBUG("Remove participant %s", call_id.c_str());
+    SFL_DBG("Remove participant %s", call_id.c_str());
 
     // this call is no longer a conference participant
     auto call = getCallFromCallID(call_id);
     if (!call) {
-        ERROR("Call not found");
+        SFL_ERR("Call not found");
         return;
     }
 
@@ -1175,7 +1175,7 @@ ManagerImpl::removeParticipant(const std::string& call_id)
 
     auto conf = iter->second;
     if (iter == conferenceMap_.end() or conf == 0) {
-        ERROR("No conference with id %s, cannot remove participant", call->getConfId().c_str());
+        SFL_ERR("No conference with id %s, cannot remove participant", call->getConfId().c_str());
         return;
     }
 
@@ -1195,7 +1195,7 @@ ManagerImpl::processRemainingParticipants(Conference &conf)
     const std::string current_call_id(getCurrentCallId());
     ParticipantSet participants(conf.getParticipantList());
     const size_t n = participants.size();
-    DEBUG("Process remaining %d participant(s) from conference %s",
+    SFL_DBG("Process remaining %d participant(s) from conference %s",
           n, conf.getConfID().c_str());
 
     if (n > 1) {
@@ -1218,10 +1218,10 @@ ManagerImpl::processRemainingParticipants(Conference &conf)
                 switchCall(call);
         }
 
-        DEBUG("No remaining participants, remove conference");
+        SFL_DBG("No remaining participants, remove conference");
         removeConference(conf.getConfID());
     } else {
-        DEBUG("No remaining participants, remove conference");
+        SFL_DBG("No remaining participants, remove conference");
         removeConference(conf.getConfID());
         unsetCurrentCall();
     }
@@ -1232,12 +1232,12 @@ ManagerImpl::joinConference(const std::string& conf_id1,
                             const std::string& conf_id2)
 {
     if (conferenceMap_.find(conf_id1) == conferenceMap_.end()) {
-        ERROR("Not a valid conference ID: %s", conf_id1.c_str());
+        SFL_ERR("Not a valid conference ID: %s", conf_id1.c_str());
         return false;
     }
 
     if (conferenceMap_.find(conf_id2) == conferenceMap_.end()) {
-        ERROR("Not a valid conference ID: %s", conf_id2.c_str());
+        SFL_ERR("Not a valid conference ID: %s", conf_id2.c_str());
         return false;
     }
 
@@ -1253,10 +1253,10 @@ ManagerImpl::joinConference(const std::string& conf_id1,
 void
 ManagerImpl::addStream(const std::string& call_id)
 {
-    DEBUG("Add audio stream %s", call_id.c_str());
+    SFL_DBG("Add audio stream %s", call_id.c_str());
     auto call = getCallFromCallID(call_id);
     if (call and isConferenceParticipant(call_id)) {
-        DEBUG("Add stream to conference");
+        SFL_DBG("Add stream to conference");
 
         // bind to conference participant
         ConferenceMap::iterator iter = conferenceMap_.find(call->getConfId());
@@ -1268,14 +1268,14 @@ ManagerImpl::addStream(const std::string& call_id)
         }
 
     } else {
-        DEBUG("Add stream to call");
+        SFL_DBG("Add stream to call");
 
         // bind to main
         getRingBufferPool().bindCallID(call_id, sfl::RingBufferPool::DEFAULT_ID);
 
         std::lock_guard<std::mutex> lock(audioLayerMutex_);
         if (!audiodriver_) {
-            ERROR("Audio driver not initialized");
+            SFL_ERR("Audio driver not initialized");
             return;
         }
         audiodriver_->flushUrgent();
@@ -1286,7 +1286,7 @@ ManagerImpl::addStream(const std::string& call_id)
 void
 ManagerImpl::removeStream(const std::string& call_id)
 {
-    DEBUG("Remove audio stream %s", call_id.c_str());
+    SFL_DBG("Remove audio stream %s", call_id.c_str());
     getRingBufferPool().unBindAll(call_id);
 }
 
@@ -1318,7 +1318,7 @@ void ManagerImpl::pollEvents()
 void
 ManagerImpl::saveConfig()
 {
-    DEBUG("Saving Configuration to XDG directory %s", path_.c_str());
+    SFL_DBG("Saving Configuration to XDG directory %s", path_.c_str());
 
     if (audiodriver_) {
         audioPreference.setVolumemic(audiodriver_->getCaptureGain());
@@ -1352,9 +1352,9 @@ ManagerImpl::saveConfig()
         std::ofstream fout(path_);
         fout << out.c_str();
     } catch (const YAML::Exception &e) {
-        ERROR("%s", e.what());
+        SFL_ERR("%s", e.what());
     } catch (const std::runtime_error &e) {
-        ERROR("%s", e.what());
+        SFL_ERR("%s", e.what());
     }
 }
 
@@ -1379,7 +1379,7 @@ ManagerImpl::playDtmf(char code)
     stopTone();
 
     if (not voipPreferences.getPlayDtmf()) {
-        DEBUG("Do not have to play a tone...");
+        SFL_DBG("Do not have to play a tone...");
         return;
     }
 
@@ -1387,7 +1387,7 @@ ManagerImpl::playDtmf(char code)
     int pulselen = voipPreferences.getPulseLength();
 
     if (pulselen == 0) {
-        DEBUG("Pulse length is not set...");
+        SFL_DBG("Pulse length is not set...");
         return;
     }
 
@@ -1398,7 +1398,7 @@ ManagerImpl::playDtmf(char code)
 
     // fast return, no sound, so no dtmf
     if (not audiodriver_ or not dtmfKey_) {
-        DEBUG("No audio layer...");
+        SFL_DBG("No audio layer...");
         return;
     }
 
@@ -1423,7 +1423,7 @@ ManagerImpl::playDtmf(char code)
         // FIXME: do real synchronization
         int tries = 10;
         while (not audiodriver_->isStarted() and tries--) {
-            WARN("Audio layer not ready yet");
+            SFL_WARN("Audio layer not ready yet");
             usleep(10000);
         }
         audiodriver_->putUrgent(dtmfBuf_);
@@ -1509,12 +1509,12 @@ ManagerImpl::incomingMessage(const std::string& callID,
             if (item_p == callID)
                 continue;
 
-            DEBUG("Send message to %s", item_p.c_str());
+            SFL_DBG("Send message to %s", item_p.c_str());
 
             if (auto call = getCallFromCallID(item_p)) {
                 call->sendTextMessage(message, from);
             } else {
-                ERROR("Failed to get call while sending instant message");
+                SFL_ERR("Failed to get call while sending instant message");
                 return;
             }
         }
@@ -1533,7 +1533,7 @@ ManagerImpl::sendTextMessage(const std::string& callID,
                              const std::string& from)
 {
     if (isConference(callID)) {
-        DEBUG("Is a conference, send instant message to everyone");
+        SFL_DBG("Is a conference, send instant message to everyone");
         ConferenceMap::iterator it = conferenceMap_.find(callID);
 
         if (it == conferenceMap_.end())
@@ -1551,7 +1551,7 @@ ManagerImpl::sendTextMessage(const std::string& callID,
             if (auto call = getCallFromCallID(participant_id)) {
                 call->sendTextMessage(message, from);
             } else {
-                ERROR("Failed to get call while sending instant message");
+                SFL_ERR("Failed to get call while sending instant message");
                 return false;
             }
         }
@@ -1560,7 +1560,7 @@ ManagerImpl::sendTextMessage(const std::string& callID,
     }
 
     if (isConferenceParticipant(callID)) {
-        DEBUG("Call is participant in a conference, send instant message to everyone");
+        SFL_DBG("Call is participant in a conference, send instant message to everyone");
         auto conf = getConferenceFromCallID(callID);
 
         if (!conf)
@@ -1573,7 +1573,7 @@ ManagerImpl::sendTextMessage(const std::string& callID,
             if (auto call = getCallFromCallID(participant_id)) {
                 call->sendTextMessage(message, from);
             } else {
-                ERROR("Failed to get call while sending instant message");
+                SFL_ERR("Failed to get call while sending instant message");
                 return false;
             }
         }
@@ -1581,7 +1581,7 @@ ManagerImpl::sendTextMessage(const std::string& callID,
         if (auto call = getCallFromCallID(callID)) {
             call->sendTextMessage(message, from);
         } else {
-            ERROR("Failed to get call while sending instant message");
+            SFL_ERR("Failed to get call while sending instant message");
             return false;
         }
     }
@@ -1595,7 +1595,7 @@ ManagerImpl::peerAnsweredCall(const std::string& id)
 {
     auto call = getCallFromCallID(id);
     if (!call) return;
-    DEBUG("Peer answered call %s", id.c_str());
+    SFL_DBG("Peer answered call %s", id.c_str());
 
     // The if statement is usefull only if we sent two calls at the same time.
     if (isCurrentCall(*call))
@@ -1622,7 +1622,7 @@ ManagerImpl::peerRingingCall(const std::string& id)
 {
     auto call = getCallFromCallID(id);
     if (!call) return;
-    DEBUG("Peer call %s ringing", id.c_str());
+    SFL_DBG("Peer call %s ringing", id.c_str());
 
     if (isCurrentCall(*call))
         ringback();
@@ -1637,7 +1637,7 @@ ManagerImpl::peerHungupCall(const std::string& call_id)
     auto call = getCallFromCallID(call_id);
     if (!call) return;
 
-    DEBUG("Peer hungup call %s", call_id.c_str());
+    SFL_DBG("Peer hungup call %s", call_id.c_str());
 
     if (isConferenceParticipant(call_id)) {
         removeParticipant(call_id);
@@ -1693,7 +1693,7 @@ ManagerImpl::callFailure(const std::string& call_id)
     }
 
     if (isConferenceParticipant(call_id)) {
-        DEBUG("Call %s participating in a conference failed", call_id.c_str());
+        SFL_DBG("Call %s participating in a conference failed", call_id.c_str());
         // remove this participant
         removeParticipant(call_id);
     }
@@ -1723,7 +1723,7 @@ ManagerImpl::playATone(Tone::TONEID toneId)
         std::lock_guard<std::mutex> lock(audioLayerMutex_);
 
         if (not audiodriver_) {
-            ERROR("Audio layer not initialized");
+            SFL_ERR("Audio layer not initialized");
             return;
         }
 
@@ -1811,7 +1811,7 @@ ManagerImpl::playRingtone(const std::string& accountID)
     const auto account = getAccount(accountID);
 
     if (!account) {
-        WARN("Invalid account in ringtone");
+        SFL_WARN("Invalid account in ringtone");
         return;
     }
 
@@ -1834,7 +1834,7 @@ ManagerImpl::playRingtone(const std::string& accountID)
         std::lock_guard<std::mutex> lock(audioLayerMutex_);
 
         if (not audiodriver_) {
-            ERROR("no audio layer in ringtone");
+            SFL_ERR("no audio layer in ringtone");
             return;
         }
 
@@ -1854,7 +1854,7 @@ ManagerImpl::playRingtone(const std::string& accountID)
         try {
             updateAudioFile(ringchoice, audioLayerSmplr);
         } catch (const AudioFileException &e) {
-            WARN("Ringtone error: %s", e.what());
+            SFL_WARN("Ringtone error: %s", e.what());
             doFallback = true; // do ringback once lock is out of scope
         }
     } // leave mutex
@@ -1909,7 +1909,7 @@ ManagerImpl::retrieveConfigPath() const
     if (mkdir(configdir.data(), 0700) != 0) {
         // If directory creation failed
         if (errno != EEXIST)
-            DEBUG("Cannot create directory: %s!", configdir.c_str());
+            SFL_DBG("Cannot create directory: %s!", configdir.c_str());
     }
 
     static const char * const PROGNAME = "sflphoned";
@@ -1934,7 +1934,7 @@ ManagerImpl::setAudioPlugin(const std::string& audioPlugin)
     if (audiodriver_ and wasStarted)
         audiodriver_->startStream();
     else
-        ERROR("No audio layer created, possibly built without audio support");
+        SFL_ERR("No audio layer created, possibly built without audio support");
 }
 
 /**
@@ -1946,7 +1946,7 @@ ManagerImpl::setAudioDevice(int index, DeviceType type)
     std::lock_guard<std::mutex> lock(audioLayerMutex_);
 
     if (not audiodriver_) {
-        ERROR("Audio driver not initialized");
+        SFL_ERR("Audio driver not initialized");
         return ;
     }
 
@@ -2007,7 +2007,7 @@ ManagerImpl::isRingtoneEnabled(const std::string& id)
     const auto account = getAccount(id);
 
     if (!account) {
-        WARN("Invalid account in ringtone enabled");
+        SFL_WARN("Invalid account in ringtone enabled");
         return 0;
     }
 
@@ -2020,7 +2020,7 @@ ManagerImpl::ringtoneEnabled(const std::string& id)
     const auto account = getAccount(id);
 
     if (!account) {
-        WARN("Invalid account in ringtone enabled");
+        SFL_WARN("Invalid account in ringtone enabled");
         return;
     }
 
@@ -2046,10 +2046,10 @@ ManagerImpl::toggleRecordingCall(const std::string& id)
 
     ConferenceMap::const_iterator it(conferenceMap_.find(id));
     if (it == conferenceMap_.end()) {
-        DEBUG("toggle recording for call %s", id.c_str());
+        SFL_DBG("toggle recording for call %s", id.c_str());
         rec = getCallFromCallID(id);
     } else {
-        DEBUG("toggle recording for conference %s", id.c_str());
+        SFL_DBG("toggle recording for conference %s", id.c_str());
         auto conf = it->second;
         if (conf) {
             rec = conf;
@@ -2061,7 +2061,7 @@ ManagerImpl::toggleRecordingCall(const std::string& id)
     }
 
     if (!rec) {
-        ERROR("Could not find recordable instance %s", id.c_str());
+        SFL_ERR("Could not find recordable instance %s", id.c_str());
         return false;
     }
 
@@ -2081,14 +2081,14 @@ ManagerImpl::isRecording(const std::string& id)
 bool
 ManagerImpl::startRecordedFilePlayback(const std::string& filepath)
 {
-    DEBUG("Start recorded file playback %s", filepath.c_str());
+    SFL_DBG("Start recorded file playback %s", filepath.c_str());
 
     int sampleRate;
     {
         std::lock_guard<std::mutex> lock(audioLayerMutex_);
 
         if (not audiodriver_) {
-            ERROR("No audio layer in start recorded file playback");
+            SFL_ERR("No audio layer in start recorded file playback");
             return false;
         }
 
@@ -2108,7 +2108,7 @@ ManagerImpl::startRecordedFilePlayback(const std::string& filepath)
             if (not audiofile_)
                 return false;
         } catch (const AudioFileException &e) {
-            WARN("Audio file error: %s", e.what());
+            SFL_WARN("Audio file error: %s", e.what());
             return false;
         }
     } // release toneMutex
@@ -2130,7 +2130,7 @@ void ManagerImpl::recordingPlaybackSeek(const double value)
 
 void ManagerImpl::stopRecordedFilePlayback(const std::string& filepath)
 {
-    DEBUG("Stop recorded file playback %s", filepath.c_str());
+    SFL_DBG("Stop recorded file playback %s", filepath.c_str());
 
     checkAudio();
 
@@ -2143,7 +2143,7 @@ void ManagerImpl::stopRecordedFilePlayback(const std::string& filepath)
 
 void ManagerImpl::setHistoryLimit(int days)
 {
-    DEBUG("Set history limit");
+    SFL_DBG("Set history limit");
     preferences.setHistoryLimit(days);
     saveConfig();
 }
@@ -2164,7 +2164,7 @@ ManagerImpl::setAudioManager(const std::string &api)
             return false;
 
         if (api == audioPreference.getAudioApi()) {
-            DEBUG("Audio manager chosen already in use. No changes made. ");
+            SFL_DBG("Audio manager chosen already in use. No changes made. ");
             return true;
         }
     }
@@ -2198,7 +2198,7 @@ ManagerImpl::getAudioInputDeviceIndex(const std::string &name)
     std::lock_guard<std::mutex> lock(audioLayerMutex_);
 
     if (not audiodriver_) {
-        ERROR("Audio layer not initialized");
+        SFL_ERR("Audio layer not initialized");
         return 0;
     }
 
@@ -2211,7 +2211,7 @@ ManagerImpl::getAudioOutputDeviceIndex(const std::string &name)
     std::lock_guard<std::mutex> lock(audioLayerMutex_);
 
     if (not audiodriver_) {
-        ERROR("Audio layer not initialized");
+        SFL_ERR("Audio layer not initialized");
         return 0;
     }
 
@@ -2274,7 +2274,7 @@ ManagerImpl::audioFormatUsed(AudioFormat format)
     if (currentFormat == format)
         return;
 
-    DEBUG("Audio format changed: %s -> %s", currentFormat.toString().c_str(), format.toString().c_str());
+    SFL_DBG("Audio format changed: %s -> %s", currentFormat.toString().c_str(), format.toString().c_str());
 
     ringbufferpool_->setInternalAudioFormat(format);
 
@@ -2288,7 +2288,7 @@ ManagerImpl::audioFormatUsed(AudioFormat format)
 void
 ManagerImpl::setAccountsOrder(const std::string& order)
 {
-    DEBUG("Set accounts order : %s", order.c_str());
+    SFL_DBG("Set accounts order : %s", order.c_str());
     // Set the new config
 
     preferences.setAccountOrder(order);
@@ -2333,7 +2333,7 @@ ManagerImpl::getAccountList() const
     if (const auto& account = getIP2IPAccount())
         v.push_back(account->getAccountID());
     else
-        ERROR("could not find IP2IP profile in getAccount list");
+        SFL_ERR("could not find IP2IP profile in getAccount list");
 
     return v;
 }
@@ -2346,7 +2346,7 @@ ManagerImpl::getAccountDetails(const std::string& accountID) const
     if (account) {
         return account->getAccountDetails();
     } else {
-        ERROR("Could not get account details on a non-existing accountID %s", accountID.c_str());
+        SFL_ERR("Could not get account details on a non-existing accountID %s", accountID.c_str());
         // return an empty map since we can't throw an exception to D-Bus
         return std::map<std::string, std::string>();
     }
@@ -2360,7 +2360,7 @@ ManagerImpl::getVolatileAccountDetails(const std::string& accountID) const
     if (account) {
         return account->getVolatileAccountDetails();
     } else {
-        ERROR("Could not get volatile account details on a non-existing accountID %s", accountID.c_str());
+        SFL_ERR("Could not get volatile account details on a non-existing accountID %s", accountID.c_str());
         return {{}};
     }
 }
@@ -2373,12 +2373,12 @@ void
 ManagerImpl::setAccountDetails(const std::string& accountID,
                                const std::map<std::string, std::string>& details)
 {
-    DEBUG("Set account details for %s", accountID.c_str());
+    SFL_DBG("Set account details for %s", accountID.c_str());
 
     const auto account = getAccount(accountID);
 
     if (account == nullptr) {
-        ERROR("Could not find account %s", accountID.c_str());
+        SFL_ERR("Could not find account %s", accountID.c_str());
         return;
     }
 
@@ -2426,11 +2426,11 @@ ManagerImpl::addAccount(const std::map<std::string, std::string>& details)
     else
         accountType = AccountFactory::DEFAULT_ACCOUNT_TYPE;
 
-    DEBUG("Adding account %s", newAccountID.c_str());
+    SFL_DBG("Adding account %s", newAccountID.c_str());
 
     auto newAccount = accountFactory_.createAccount(accountType, newAccountID);
     if (!newAccount) {
-        ERROR("Unknown %s param when calling addAccount(): %s",
+        SFL_ERR("Unknown %s param when calling addAccount(): %s",
               CONFIG_ACCOUNT_TYPE, accountType);
         return "";
     }
@@ -2519,7 +2519,7 @@ ManagerImpl::loadAccount(const YAML::Node &node, int &errorCount,
     if (!accountid.empty() and !accountAlias.empty()) {
         const auto& ip2ipAccountID = getIP2IPAccount()->getAccountID();
         if (not inAccountOrder(accountid) and accountid != ip2ipAccountID) {
-            WARN("Dropping account %s, which is not in account order", accountid.c_str());
+            SFL_WARN("Dropping account %s, which is not in account order", accountid.c_str());
         } else if (accountFactory_.isSupportedType(accountType.c_str())) {
             std::shared_ptr<Account> a;
             if (accountid != ip2ipAccountID)
@@ -2529,11 +2529,11 @@ ManagerImpl::loadAccount(const YAML::Node &node, int &errorCount,
             if (a) {
                 a->unserialize(node);
             } else {
-                ERROR("Failed to create account type \"%s\"", accountType.c_str());
+                SFL_ERR("Failed to create account type \"%s\"", accountType.c_str());
                 ++errorCount;
             }
         } else {
-            ERROR("Ignoring unknown account type \"%s\"", accountType.c_str());
+            SFL_ERR("Ignoring unknown account type \"%s\"", accountType.c_str());
             ++errorCount;
         }
     }
@@ -2560,7 +2560,7 @@ ManagerImpl::loadAccountMap(const YAML::Node &node)
         controls->getVideoDeviceMonitor().unserialize(node);
 #endif
     } catch (const YAML::Exception &e) {
-        ERROR("%s: No video node in config file", e.what());
+        SFL_ERR("%s: No video node in config file", e.what());
         ++errorCount;
     }
 
@@ -2582,7 +2582,7 @@ ManagerImpl::getCallDetails(const std::string &callID)
     if (auto call = getCallFromCallID(callID)) {
         return call->getDetails();
     } else {
-        ERROR("Call is NULL");
+        SFL_ERR("Call is NULL");
         // FIXME: is this even useful?
         return Call::getNullDetails();
     }
@@ -2632,7 +2632,7 @@ ManagerImpl::getDisplayNames(const std::string& confID) const
     if (iter_conf != conferenceMap_.end()) {
         return iter_conf->second->getDisplayNames();
     } else {
-        WARN("Did not find conference %s", confID.c_str());
+        SFL_WARN("Did not find conference %s", confID.c_str());
     }
 
     return v;
@@ -2648,7 +2648,7 @@ ManagerImpl::getParticipantList(const std::string& confID) const
         const ParticipantSet participants(iter_conf->second->getParticipantList());
         std::copy(participants.begin(), participants.end(), std::back_inserter(v));;
     } else
-        WARN("Did not find conference %s", confID.c_str());
+        SFL_WARN("Did not find conference %s", confID.c_str());
 
     return v;
 }
@@ -2659,7 +2659,7 @@ ManagerImpl::getConferenceId(const std::string& callID)
     if (auto call = getCallFromCallID(callID))
         return call->getConfId();
 
-    ERROR("Call is NULL");
+    SFL_ERR("Call is NULL");
     return "";
 }
 
@@ -2667,7 +2667,7 @@ void
 ManagerImpl::saveHistory()
 {
     if (!history_.save())
-        ERROR("Could not save history!");
+        SFL_ERR("Could not save history!");
     else
         client_.getConfigurationManager()->historyChanged();
 }
@@ -2683,7 +2683,7 @@ ManagerImpl::startAudioDriverStream()
 {
     std::lock_guard<std::mutex> lock(audioLayerMutex_);
     if (!audiodriver_) {
-        ERROR("Audio driver not initialized");
+        SFL_ERR("Audio driver not initialized");
         return;
     }
     audiodriver_->startStream();
@@ -2764,7 +2764,7 @@ ManagerImpl::newOutgoingCall(const std::string& id,
 
 #if HAVE_DHT
     if (toUrl.find("dht:") != std::string::npos) {
-        WARN("DHT call detected");
+        SFL_WARN("DHT call detected");
         auto dhtAcc = getAllAccounts<DHTAccount>();
         if (not dhtAcc.empty())
             return dhtAcc.front()->newOutgoingCall(id, finalToUrl);
@@ -2779,13 +2779,13 @@ ManagerImpl::newOutgoingCall(const std::string& id,
         if (account)
             finalToUrl = toUrl;
         else
-            WARN("Preferred account %s doesn't exist, using IP2IP account",
+            SFL_WARN("Preferred account %s doesn't exist, using IP2IP account",
                  preferredAccountId.c_str());
     } else
-        WARN("IP Url detected, using IP2IP account");
+        SFL_WARN("IP Url detected, using IP2IP account");
 
     if (!account) {
-        ERROR("No suitable account found to create outgoing call");
+        SFL_ERR("No suitable account found to create outgoing call");
         return nullptr;
     }
 
diff --git a/daemon/src/plugin_manager.cpp b/daemon/src/plugin_manager.cpp
index c4ce46bbf19e7efbe2d1fb27326a32d221b4b2ae..1b690188f86b30b34abcb53e18a687cf5adff43b 100644
--- a/daemon/src/plugin_manager.cpp
+++ b/daemon/src/plugin_manager.cpp
@@ -65,7 +65,7 @@ int PluginManager::initPlugin(SFLPluginInitFunc initFunc)
     if (!exitFunc) {
         tempExactMatchMap_.clear();
         tempWildCardVec_.clear();
-        DEBUG("plugin: init failed");
+        SFL_DBG("plugin: init failed");
         return -1;
     }
 
@@ -127,21 +127,21 @@ int PluginManager::load(const std::string& path)
 
     // Don't load the same dynamic library twice
     if (dynPluginMap_.find(std::string(path)) != dynPluginMap_.end()) {
-        DEBUG("plugin: already loaded");
+        SFL_DBG("plugin: already loaded");
         return -1;
     }
 
     std::string error;
     Plugin *plugin = Plugin::load(std::string(path), error);
     if (!plugin) {
-        DEBUG("plugin: %s", error.c_str());
+        SFL_DBG("plugin: %s", error.c_str());
         return -1;
     }
 
     SFLPluginInitFunc init_func;
     init_func = (SFLPluginInitFunc)(plugin->getInitFunction());
     if (!init_func) {
-        DEBUG("plugin: no init symbol");
+        SFL_DBG("plugin: no init symbol");
         return -1;
     }
 
@@ -189,7 +189,7 @@ void* PluginManager::createObject(const std::string& type)
             // (but keep also the wild card registration for other object types)
             int32_t res = registerObject_(op.type, &rp);
             if (res < 0) {
-                ERROR("failed to register object %s", op.type);
+                SFL_ERR("failed to register object %s", op.type);
                 rp.destroy(object);
                 return nullptr;
             }
diff --git a/daemon/src/preferences.cpp b/daemon/src/preferences.cpp
index a7f78b7f908ff95c7ec46770378be80b71ec92ea..42df253cf313fb60e3b007d3a82636efae6089bc 100644
--- a/daemon/src/preferences.cpp
+++ b/daemon/src/preferences.cpp
@@ -147,7 +147,7 @@ void Preferences::verifyAccountOrder(const std::vector<std::string> &accountIDs)
             if (find(accountIDs.begin(), accountIDs.end(), token) != accountIDs.end())
                 tokens.push_back(token);
             else {
-                DEBUG("Dropping nonexistent account %s", token.c_str());
+                SFL_DBG("Dropping nonexistent account %s", token.c_str());
                 drop = true;
             }
             token.clear();
@@ -328,7 +328,7 @@ static void
 checkSoundCard(int &card, sfl::DeviceType type)
 {
     if (not sfl::AlsaLayer::soundCardIndexExists(card, type)) {
-        WARN(" Card with index %d doesn't exist or is unusable.", card);
+        SFL_WARN(" Card with index %d doesn't exist or is unusable.", card);
         card = ALSA_DFT_CARD_ID;
     }
 }
@@ -346,9 +346,9 @@ sfl::AudioLayer* AudioPreference::createAudioLayer()
             try {
                 return new sfl::JackLayer(*this);
             } catch (const std::runtime_error &e) {
-                ERROR("%s", e.what());
+                SFL_ERR("%s", e.what());
 #if HAVE_PULSE
-                WARN("falling back to pulseaudio");
+                SFL_WARN("falling back to pulseaudio");
                 audioApi_ = PULSEAUDIO_API_STR;
 #elif HAVE_ALSA
                 audioApi_ = ALSA_API_STR;
@@ -366,7 +366,7 @@ sfl::AudioLayer* AudioPreference::createAudioLayer()
         try {
             return new sfl::PulseLayer(*this);
         } catch (const std::runtime_error &e) {
-            WARN("Could not create pulseaudio layer, falling back to ALSA");
+            SFL_WARN("Could not create pulseaudio layer, falling back to ALSA");
         }
     }
 
@@ -430,7 +430,7 @@ AudioPreference::setRecordPath(const std::string &r)
         recordpath_ = path;
         return true;
     } else {
-        ERROR("%s is not writable, cannot be the recording path", path.c_str());
+        SFL_ERR("%s is not writable, cannot be the recording path", path.c_str());
         return false;
     }
 }
diff --git a/daemon/src/sip/pres_sub_client.cpp b/daemon/src/sip/pres_sub_client.cpp
index 3e9084187cb530e211ffaa38e1b55e59aebc650b..c990c7c6f2be8fe002e5fc7d438518c68d1640d7 100644
--- a/daemon/src/sip/pres_sub_client.cpp
+++ b/daemon/src/sip/pres_sub_client.cpp
@@ -64,7 +64,7 @@ void
 PresSubClient::pres_client_timer_cb(pj_timer_heap_t * /*th*/, pj_timer_entry *entry)
 {
     PresSubClient *c = (PresSubClient *) entry->user_data;
-    DEBUG("timeout for %s", c->getURI().c_str());
+    SFL_DBG("timeout for %s", c->getURI().c_str());
 }
 
 /* Callback called when *client* subscription state has changed. */
@@ -77,11 +77,11 @@ PresSubClient::pres_client_evsub_on_state(pjsip_evsub *sub, pjsip_event *event)
     /* No need to pres->lock() here since the client has a locked dialog*/
 
     if (!pres_client) {
-        WARN("pres_client not found");
+        SFL_WARN("pres_client not found");
         return;
     }
 
-    DEBUG("Subscription for pres_client '%s' is '%s'", pres_client->getURI().c_str(),
+    SFL_DBG("Subscription for pres_client '%s' is '%s'", pres_client->getURI().c_str(),
             pjsip_evsub_get_state_name(sub) ? pjsip_evsub_get_state_name(sub) : "null");
 
     pjsip_evsub_state state = pjsip_evsub_get_state(sub);
@@ -256,7 +256,7 @@ PresSubClient::pres_client_evsub_on_tsx_state(pjsip_evsub *sub, pjsip_transactio
     /* No need to pres->lock() here since the client has a locked dialog*/
 
     if (!pres_client) {
-        WARN("Couldn't find pres_client.");
+        SFL_WARN("Couldn't find pres_client.");
         return;
     }
 
@@ -299,7 +299,7 @@ PresSubClient::pres_client_evsub_on_rx_notify(pjsip_evsub *sub, pjsip_rx_data *r
     PresSubClient *pres_client = (PresSubClient *) pjsip_evsub_get_mod_data(sub, modId_);
 
     if (!pres_client) {
-        WARN("Couldn't find pres_client from ev_sub.");
+        SFL_WARN("Couldn't find pres_client from ev_sub.");
         return;
     }
     /* No need to pres->lock() here since the client has a locked dialog*/
@@ -344,7 +344,7 @@ PresSubClient::PresSubClient(const std::string& uri, SIPPresence *pres) :
 
 PresSubClient::~PresSubClient()
 {
-    DEBUG("Destroying pres_client object with uri %.*s", uri_.slen, uri_.ptr);
+    SFL_DBG("Destroying pres_client object with uri %.*s", uri_.slen, uri_.ptr);
     rescheduleTimer(PJ_FALSE, 0);
     unsubscribe();
     pj_pool_release(pool_);
@@ -392,7 +392,7 @@ void PresSubClient::rescheduleTimer(bool reschedule, unsigned msec)
     if (reschedule) {
         pj_time_val delay;
 
-        WARN("pres_client  %.*s will resubscribe in %u ms (reason: %.*s)",
+        SFL_WARN("pres_client  %.*s will resubscribe in %u ms (reason: %.*s)",
              uri_.slen, uri_.ptr, msec, (int) term_reason_.slen, term_reason_.ptr);
         pj_timer_entry_init(&timer_, 0, this, &pres_client_timer_cb);
         delay.sec = 0;
@@ -407,7 +407,7 @@ void PresSubClient::rescheduleTimer(bool reschedule, unsigned msec)
 
 void PresSubClient::enable(bool flag)
 {
-    DEBUG("pres_client %s is %s monitored.",getURI().c_str(), flag? "":"NOT");
+    SFL_DBG("pres_client %s is %s monitored.",getURI().c_str(), flag? "":"NOT");
     if (flag and not monitored_)
         pres_->addPresSubClient(this);
     monitored_ = flag;
@@ -447,7 +447,7 @@ bool PresSubClient::lock()
 
     if (lock_flag_ == 0)
     {
-        DEBUG("pres_client failed to lock : timeout");
+        SFL_DBG("pres_client failed to lock : timeout");
         return false;
     }
     return true;
@@ -473,20 +473,20 @@ bool PresSubClient::unsubscribe()
     pj_status_t retStatus;
 
     if (sub_ == NULL or dlg_ == NULL) {
-        WARN("PresSubClient already unsubscribed.");
+        SFL_WARN("PresSubClient already unsubscribed.");
         unlock();
         return false;
     }
 
     if (pjsip_evsub_get_state(sub_) == PJSIP_EVSUB_STATE_TERMINATED) {
-        WARN("pres_client already unsubscribed sub=TERMINATED.");
+        SFL_WARN("pres_client already unsubscribed sub=TERMINATED.");
         sub_ = NULL;
         unlock();
         return false;
     }
 
     /* Unsubscribe means send a subscribe with timeout=0s*/
-    WARN("pres_client %.*s: unsubscribing..", uri_.slen, uri_.ptr);
+    SFL_WARN("pres_client %.*s: unsubscribing..", uri_.slen, uri_.ptr);
     retStatus = pjsip_pres_initiate(sub_, 0, &tdata);
 
     if (retStatus == PJ_SUCCESS) {
@@ -497,7 +497,7 @@ bool PresSubClient::unsubscribe()
     if (retStatus != PJ_SUCCESS and sub_) {
         pjsip_pres_terminate(sub_, PJ_FALSE);
         sub_ = NULL;
-        WARN("Unable to unsubscribe presence", retStatus);
+        SFL_WARN("Unable to unsubscribe presence", retStatus);
         unlock();
         return false;
     }
@@ -514,7 +514,7 @@ bool PresSubClient::subscribe()
 
     if (sub_ and dlg_) { //do not bother if already subscribed
         pjsip_evsub_terminate(sub_, PJ_FALSE);
-        DEBUG("PreseSubClient %.*s: already subscribed. Refresh it.", uri_.slen, uri_.ptr);
+        SFL_DBG("PreseSubClient %.*s: already subscribed. Refresh it.", uri_.slen, uri_.ptr);
     }
 
     //subscribe
@@ -529,7 +529,7 @@ bool PresSubClient::subscribe()
     pres_callback.on_rx_notify = &pres_client_evsub_on_rx_notify;
 
     SIPAccount * acc = pres_->getAccount();
-    DEBUG("PresSubClient %.*s: subscribing ", uri_.slen, uri_.ptr);
+    SFL_DBG("PresSubClient %.*s: subscribing ", uri_.slen, uri_.ptr);
 
 
     /* Create UAC dialog */
@@ -537,13 +537,13 @@ bool PresSubClient::subscribe()
     status = pjsip_dlg_create_uac(pjsip_ua_instance(), &from, &contact_, &uri_, NULL, &dlg_);
 
     if (status != PJ_SUCCESS) {
-        ERROR("Unable to create dialog \n");
+        SFL_ERR("Unable to create dialog \n");
         return false;
     }
 
     /* Add credential for auth. */
     if (acc->hasCredentials() and pjsip_auth_clt_set_credentials(&dlg_->auth_sess, acc->getCredentialCount(), acc->getCredInfo()) != PJ_SUCCESS) {
-        ERROR("Could not initialize credentials for subscribe session authentication");
+        SFL_ERR("Could not initialize credentials for subscribe session authentication");
     }
 
     /* Increment the dialog's lock otherwise when presence session creation
@@ -555,7 +555,7 @@ bool PresSubClient::subscribe()
 
     if (status != PJ_SUCCESS) {
         sub_ = NULL;
-        WARN("Unable to create presence client", status);
+        SFL_WARN("Unable to create presence client", status);
 
         /* This should destroy the dialog since there's no session
          * referencing it
@@ -569,7 +569,7 @@ bool PresSubClient::subscribe()
 
     /* Add credential for authentication */
     if (acc->hasCredentials() and pjsip_auth_clt_set_credentials(&dlg_->auth_sess, acc->getCredentialCount(), acc->getCredInfo()) != PJ_SUCCESS) {
-        ERROR("Could not initialize credentials for invite session authentication");
+        SFL_ERR("Could not initialize credentials for invite session authentication");
         return false;
     }
 
@@ -588,7 +588,7 @@ bool PresSubClient::subscribe()
         if (sub_)
             pjsip_pres_terminate(sub_, PJ_FALSE);
         sub_ = NULL;
-        WARN("Unable to create initial SUBSCRIBE", status);
+        SFL_WARN("Unable to create initial SUBSCRIBE", status);
         return false;
     }
 
@@ -602,7 +602,7 @@ bool PresSubClient::subscribe()
         if (sub_)
             pjsip_pres_terminate(sub_, PJ_FALSE);
         sub_ = NULL;
-        WARN("Unable to send initial SUBSCRIBE", status);
+        SFL_WARN("Unable to send initial SUBSCRIBE", status);
         return false;
     }
 
diff --git a/daemon/src/sip/pres_sub_server.cpp b/daemon/src/sip/pres_sub_server.cpp
index fea6a2257362b2f546a35acf491e930871d6e52a..84c8b1883358b885613c0b3045195355c9a96072 100644
--- a/daemon/src/sip/pres_sub_server.cpp
+++ b/daemon/src/sip/pres_sub_server.cpp
@@ -47,7 +47,7 @@ PresSubServer::pres_evsub_on_srv_state(pjsip_evsub *sub, pjsip_event *event)
     pjsip_rx_data *rdata = event->body.rx_msg.rdata;
 
     if (!rdata) {
-        DEBUG("Presence_subscription_server estate has changed but no rdata.");
+        SFL_DBG("Presence_subscription_server estate has changed but no rdata.");
         return;
     }
 
@@ -55,14 +55,14 @@ PresSubServer::pres_evsub_on_srv_state(pjsip_evsub *sub, pjsip_event *event)
     auto sipaccount = static_cast<SIPAccount *>(account.get());
 
     if (!sipaccount) {
-        ERROR("Could not find account IP2IP");
+        SFL_ERR("Could not find account IP2IP");
         return;
     }
 
     auto pres = sipaccount->getPresence();
 
     if (!pres) {
-        ERROR("Presence not initialized");
+        SFL_ERR("Presence not initialized");
         return;
     }
 
@@ -70,7 +70,7 @@ PresSubServer::pres_evsub_on_srv_state(pjsip_evsub *sub, pjsip_event *event)
     PresSubServer *presSubServer = static_cast<PresSubServer *>(pjsip_evsub_get_mod_data(sub, pres->getModId()));
 
     if (presSubServer) {
-        DEBUG("Presence_subscription_server to %s is %s",
+        SFL_DBG("Presence_subscription_server to %s is %s",
               presSubServer->remote_, pjsip_evsub_get_state_name(sub));
         pjsip_evsub_state state;
 
@@ -114,7 +114,7 @@ PresSubServer::pres_on_rx_subscribe_request(pjsip_rx_data *rdata)
     /* debug msg */
     std::string name(rdata->msg_info.to->name.ptr, rdata->msg_info.to->name.slen);
     std::string server(rdata->msg_info.from->name.ptr, rdata->msg_info.from->name.slen);
-    DEBUG("Incoming pres_on_rx_subscribe_request for %s, name:%s, server:%s."
+    SFL_DBG("Incoming pres_on_rx_subscribe_request for %s, name:%s, server:%s."
           , request.c_str()
           , name.c_str()
           , server.c_str());
@@ -123,7 +123,7 @@ PresSubServer::pres_on_rx_subscribe_request(pjsip_rx_data *rdata)
     auto account = Manager::instance().getIP2IPAccount();
     auto sipaccount = static_cast<SIPAccount *>(account.get());
     if (!sipaccount) {
-        ERROR("Could not find account IP2IP");
+        SFL_ERR("Could not find account IP2IP");
         return PJ_FALSE;
     }
 
@@ -138,7 +138,7 @@ PresSubServer::pres_on_rx_subscribe_request(pjsip_rx_data *rdata)
     if (status != PJ_SUCCESS) {
         char errmsg[PJ_ERR_MSG_SIZE];
         pj_strerror(status, errmsg, sizeof(errmsg));
-        WARN("Unable to create UAS dialog for subscription: %s [status=%d]", errmsg, status);
+        SFL_WARN("Unable to create UAS dialog for subscription: %s [status=%d]", errmsg, status);
         pres->unlock();
         pjsip_endpt_respond_stateless(endpt, rdata, 400, NULL, NULL, NULL);
         return PJ_TRUE;
@@ -155,7 +155,7 @@ PresSubServer::pres_on_rx_subscribe_request(pjsip_rx_data *rdata)
         int code = PJSIP_ERRNO_TO_SIP_STATUS(status);
         pjsip_tx_data *tdata;
 
-        WARN("Unable to create server subscription %d", status);
+        SFL_WARN("Unable to create server subscription %d", status);
 
         if (code == 599 || code > 699 || code < 300) {
             code = 400;
@@ -209,7 +209,7 @@ PresSubServer::pres_on_rx_subscribe_request(pjsip_rx_data *rdata)
     status = pjsip_pres_accept(sub, rdata, st_code, &msg_data.hdr_list);
 
     if (status != PJ_SUCCESS) {
-        WARN("Unable to accept presence subscription %d", status);
+        SFL_WARN("Unable to accept presence subscription %d", status);
         pjsip_pres_terminate(sub, PJ_FALSE);
         pres->unlock();
         return PJ_FALSE;
@@ -254,7 +254,7 @@ PresSubServer::pres_on_rx_subscribe_request(pjsip_rx_data *rdata)
     }
 
     if (status != PJ_SUCCESS) {
-        WARN("Unable to create/send NOTIFY %d", status);
+        SFL_WARN("Unable to create/send NOTIFY %d", status);
         pjsip_pres_terminate(sub, PJ_FALSE);
         pres->unlock();
         return status;
@@ -316,7 +316,7 @@ bool PresSubServer::matches(const char *s) const
 void PresSubServer::approve(bool flag)
 {
     approved_ = flag;
-    DEBUG("Approve Presence_subscription_server for %s: %s.", remote_, flag ? "true" : "false");
+    SFL_DBG("Approve Presence_subscription_server for %s: %s.", remote_, flag ? "true" : "false");
     // attach the real status data
     pjsip_pres_set_status(sub_, pres_->getStatus());
 }
@@ -331,7 +331,7 @@ void PresSubServer::notify()
     * the user accepted the request.
     */
     if ((pjsip_evsub_get_state(sub_) == PJSIP_EVSUB_STATE_ACTIVE) && (approved_)) {
-        DEBUG("Notifying %s.", remote_);
+        SFL_DBG("Notifying %s.", remote_);
 
         pjsip_tx_data *tdata;
         pjsip_pres_set_status(sub_, pres_->getStatus());
@@ -341,7 +341,7 @@ void PresSubServer::notify()
             pres_->fillDoc(tdata, NULL);
             pjsip_pres_send_request(sub_, tdata);
         } else {
-            WARN("Unable to create/send NOTIFY");
+            SFL_WARN("Unable to create/send NOTIFY");
             pjsip_pres_terminate(sub_, PJ_FALSE);
         }
     }
diff --git a/daemon/src/sip/sdp.cpp b/daemon/src/sip/sdp.cpp
index 491e97d7fe71e42844d9ec7130d9a3ffebbcd1d7..1731e852e83de9bec1fdfcb761d2ebb951d95683 100644
--- a/daemon/src/sip/sdp.cpp
+++ b/daemon/src/sip/sdp.cpp
@@ -133,7 +133,7 @@ void Sdp::setActiveLocalSdpSession(const pjmedia_sdp_session *sdp)
             pjmedia_sdp_attr *rtpMapAttribute = pjmedia_sdp_media_find_attr(current, &STR_RTPMAP, &current->desc.fmt[fmt]);
 
             if (!rtpMapAttribute) {
-                ERROR("Could not find rtpmap attribute");
+                SFL_ERR("Could not find rtpmap attribute");
                 break;
             }
 
@@ -151,7 +151,7 @@ void Sdp::setActiveLocalSdpSession(const pjmedia_sdp_session *sdp)
                         if (codec)
                             sessionAudioMediaLocal_.push_back(codec);
                         else
-                            ERROR("Could not get codec for name %.*s", rtpmap->enc_name.slen, rtpmap->enc_name.ptr);
+                            SFL_ERR("Could not get codec for name %.*s", rtpmap->enc_name.slen, rtpmap->enc_name.ptr);
                     }
                 }
             } else if (!pj_stricmp2(&current->desc.media, "video")) {
@@ -167,7 +167,7 @@ void Sdp::setActiveLocalSdpSession(const pjmedia_sdp_session *sdp)
 void Sdp::setActiveRemoteSdpSession(const pjmedia_sdp_session *sdp)
 {
     if (!sdp) {
-        ERROR("Remote sdp is NULL");
+        SFL_ERR("Remote sdp is NULL");
         return;
     }
 
@@ -198,7 +198,7 @@ void Sdp::setActiveRemoteSdpSession(const pjmedia_sdp_session *sdp)
                 pjmedia_sdp_attr *rtpMapAttribute = pjmedia_sdp_media_find_attr(r_media, &STR_RTPMAP, &r_media->desc.fmt[fmt]);
 
                 if (!rtpMapAttribute) {
-                    ERROR("Could not find rtpmap attribute");
+                    SFL_ERR("Could not find rtpmap attribute");
                     break;
                 }
 
@@ -209,7 +209,7 @@ void Sdp::setActiveRemoteSdpSession(const pjmedia_sdp_session *sdp)
                 if (pt != telephoneEventPayload_ and not hasPayload(sessionAudioMediaRemote_, pt)) {
                     sfl::AudioCodec *codec = Manager::instance().audioCodecFactory.getCodec(pt);
                     if (codec) {
-                        DEBUG("Adding codec with new payload type %d", pt);
+                        SFL_DBG("Adding codec with new payload type %d", pt);
                         sessionAudioMediaRemote_.push_back(codec);
                     } else {
                         // Search by codec name, clock rate and param (channel count)
@@ -217,7 +217,7 @@ void Sdp::setActiveRemoteSdpSession(const pjmedia_sdp_session *sdp)
                         if (codec)
                             sessionAudioMediaRemote_.push_back(codec);
                         else
-                            ERROR("Could not get codec for name %.*s", rtpmap->enc_name.slen, rtpmap->enc_name.ptr);
+                            SFL_ERR("Could not get codec for name %.*s", rtpmap->enc_name.slen, rtpmap->enc_name.ptr);
                     }
                 }
             }
@@ -228,7 +228,7 @@ void Sdp::setActiveRemoteSdpSession(const pjmedia_sdp_session *sdp)
 string Sdp::getSessionVideoCodec() const
 {
     if (sessionVideoMedia_.empty()) {
-        DEBUG("Session video media is empty");
+        SFL_DBG("Session video media is empty");
         return "";
     }
     return sessionVideoMedia_[0];
@@ -244,7 +244,7 @@ Sdp::getSessionAudioMedia() const
         if (std::find(sessionAudioMediaRemote_.begin(), sessionAudioMediaRemote_.end(), c) != sessionAudioMediaRemote_.end())
             codecs.push_back(c);
     }
-    DEBUG("%u common audio codecs", codecs.size());
+    SFL_DBG("%u common audio codecs", codecs.size());
 
     // Next, the other codecs we declared to be able to encode
     for (auto c : sessionAudioMediaLocal_) {
@@ -256,7 +256,7 @@ Sdp::getSessionAudioMedia() const
         if (std::find(codecs.begin(), codecs.end(), c) == codecs.end())
             codecs.push_back(c);
     }
-    DEBUG("Ready to decode %u audio codecs", codecs.size());
+    SFL_DBG("Ready to decode %u audio codecs", codecs.size());
 
     return codecs;
 }
@@ -371,7 +371,7 @@ Sdp::setPublishedIP(const std::string &addr, pj_uint16_t addr_type)
         localSession_->origin.addr = pj_str((char*) publishedIpAddr_.c_str());
         localSession_->conn->addr = localSession_->origin.addr;
         if (pjmedia_sdp_validate(localSession_) != PJ_SUCCESS)
-            ERROR("Could not validate SDP");
+            SFL_ERR("Could not validate SDP");
     }
 }
 
@@ -405,7 +405,7 @@ Sdp::updatePorts(const std::vector<pj_sockaddr> &sockets)
             localSession_->media[1]->desc.port = localVideoDataPort_;
 
         if (not pjmedia_sdp_validate(localSession_))
-            ERROR("Could not validate SDP");
+            SFL_ERR("Could not validate SDP");
     }
 }
 
@@ -435,7 +435,7 @@ void Sdp::setLocalMediaVideoCapabilities(const vector<map<string, string> > &cod
     video_codec_list_.clear();
 #ifdef SFL_VIDEO
     if (codecs.empty())
-        WARN("No selected video codec while building local SDP offer");
+        SFL_WARN("No selected video codec while building local SDP offer");
     else
         video_codec_list_ = codecs;
 #else
@@ -446,7 +446,7 @@ void Sdp::setLocalMediaVideoCapabilities(const vector<map<string, string> > &cod
 void Sdp::setLocalMediaAudioCapabilities(const vector<int> &selectedCodecs)
 {
     if (selectedCodecs.empty())
-        WARN("No selected codec while building local SDP offer");
+        SFL_WARN("No selected codec while building local SDP offer");
 
     audio_codec_list_.clear();
     for (const auto &i : selectedCodecs) {
@@ -455,7 +455,7 @@ void Sdp::setLocalMediaAudioCapabilities(const vector<int> &selectedCodecs)
         if (codec)
             audio_codec_list_.push_back(codec);
         else
-            WARN("Couldn't find audio codec");
+            SFL_WARN("Couldn't find audio codec");
     }
 }
 
@@ -465,7 +465,7 @@ printSession(const pjmedia_sdp_session *session)
     char buffer[2048];
     size_t size = pjmedia_sdp_print(session, buffer, sizeof(buffer));
     string sessionStr(buffer, std::min(size, sizeof(buffer)));
-    DEBUG("%s", sessionStr.c_str());
+    SFL_DBG("%s", sessionStr.c_str());
 }
 
 int Sdp::createLocalSession(const vector<int> &selectedAudioCodecs, const vector<map<string, string> > &selectedVideoCodecs)
@@ -515,7 +515,7 @@ int Sdp::createLocalSession(const vector<int> &selectedAudioCodecs, const vector
     if (!srtpCrypto_.empty())
         addSdesAttribute(srtpCrypto_);
 
-    DEBUG("SDP: Local SDP Session:");
+    SFL_DBG("SDP: Local SDP Session:");
     printSession(localSession_);
 
     return pjmedia_sdp_validate(localSession_);
@@ -526,12 +526,12 @@ Sdp::createOffer(const vector<int> &selectedCodecs,
                  const vector<map<string, string> > &videoCodecs)
 {
     if (createLocalSession(selectedCodecs, videoCodecs) != PJ_SUCCESS) {
-        ERROR("Failed to create initial offer");
+        SFL_ERR("Failed to create initial offer");
         return false;
     }
 
     if (pjmedia_sdp_neg_create_w_local_offer(memPool_, localSession_, &negotiator_) != PJ_SUCCESS) {
-        ERROR("Failed to create an initial SDP negotiator");
+        SFL_ERR("Failed to create an initial SDP negotiator");
         return false;
     }
     return true;
@@ -542,15 +542,15 @@ void Sdp::receiveOffer(const pjmedia_sdp_session* remote,
                        const vector<map<string, string> > &videoCodecs)
 {
     if (!remote) {
-        ERROR("Remote session is NULL");
+        SFL_ERR("Remote session is NULL");
         return;
     }
 
-    DEBUG("Remote SDP Session:");
+    SFL_DBG("Remote SDP Session:");
     printSession(remote);
 
     if (!localSession_ and createLocalSession(selectedCodecs, videoCodecs) != PJ_SUCCESS) {
-        ERROR("Failed to create initial offer");
+        SFL_ERR("Failed to create initial offer");
         return;
     }
 
@@ -558,13 +558,13 @@ void Sdp::receiveOffer(const pjmedia_sdp_session* remote,
 
     if (pjmedia_sdp_neg_create_w_remote_offer(memPool_, localSession_,
             remoteSession_, &negotiator_) != PJ_SUCCESS)
-        ERROR("Failed to initialize negotiator");
+        SFL_ERR("Failed to initialize negotiator");
 }
 
 void Sdp::startNegotiation()
 {
     if (negotiator_ == NULL) {
-        ERROR("Can't start negotiation with invalid negotiator");
+        SFL_ERR("Can't start negotiation with invalid negotiator");
         return;
     }
 
@@ -572,7 +572,7 @@ void Sdp::startNegotiation()
     const pjmedia_sdp_session *active_remote;
 
     if (pjmedia_sdp_neg_get_state(negotiator_) != PJMEDIA_SDP_NEG_STATE_WAIT_NEGO) {
-        WARN("Negotiator not in right state for negotiation");
+        SFL_WARN("Negotiator not in right state for negotiation");
         return;
     }
 
@@ -580,12 +580,12 @@ void Sdp::startNegotiation()
         return;
 
     if (pjmedia_sdp_neg_get_active_local(negotiator_, &active_local) != PJ_SUCCESS)
-        ERROR("Could not retrieve local active session");
+        SFL_ERR("Could not retrieve local active session");
     else
         setActiveLocalSdpSession(active_local);
 
     if (pjmedia_sdp_neg_get_active_remote(negotiator_, &active_remote) != PJ_SUCCESS)
-        ERROR("Could not retrieve remote active session");
+        SFL_ERR("Could not retrieve remote active session");
     else
         setActiveRemoteSdpSession(active_remote);
 }
@@ -623,7 +623,7 @@ string Sdp::getIncomingVideoDescription() const
 {
     pjmedia_sdp_session *videoSession = pjmedia_sdp_session_clone(memPool_, activeLocalSession_);
     if (!videoSession) {
-        ERROR("Could not clone SDP");
+        SFL_ERR("Could not clone SDP");
         return "";
     }
 
@@ -632,13 +632,13 @@ string Sdp::getIncomingVideoDescription() const
     for (unsigned i = 0; i < videoSession->media_count; i++)
         if (pj_stricmp2(&videoSession->media[i]->desc.media, "video")) {
             if (pjmedia_sdp_media_deactivate(memPool_, videoSession->media[i]) != PJ_SUCCESS)
-                ERROR("Could not deactivate media");
+                SFL_ERR("Could not deactivate media");
         } else {
             hasVideo = true;
         }
 
     if (not hasVideo) {
-        DEBUG("No video present in active local SDP");
+        SFL_DBG("No video present in active local SDP");
         return "";
     }
 
@@ -715,7 +715,7 @@ Sdp::getProfileLevelID(const pjmedia_sdp_session *session,
     const size_t pos = fmtpLine.find(needle);
     if (pos != std::string::npos and fmtpLine.size() >= (pos + needleLength)) {
         profile = fmtpLine.substr(pos, needleLength);
-        DEBUG("Using %s", profile.c_str());
+        SFL_DBG("Using %s", profile.c_str());
     }
 }
 
@@ -748,7 +748,7 @@ static int
 getIndexOfAttribute(const pjmedia_sdp_session * const session, const char * const type)
 {
     if (!session) {
-        ERROR("Session is NULL when looking for \"%s\" attribute", type);
+        SFL_ERR("Session is NULL when looking for \"%s\" attribute", type);
         return -1;
     }
     size_t i = 0;
@@ -807,14 +807,14 @@ Sdp::updateRemoteIP(unsigned index)
     if (conn)
         remoteIpAddr_ = std::string(conn->addr.ptr, conn->addr.slen);
     else
-        ERROR("Could not get remote IP from SDP or SDP Media");
+        SFL_ERR("Could not get remote IP from SDP or SDP Media");
 }
 
 
 void Sdp::setMediaTransportInfoFromRemoteSdp()
 {
     if (!activeRemoteSession_) {
-        ERROR("Remote sdp is NULL while parsing media");
+        SFL_ERR("Remote sdp is NULL while parsing media");
         return;
     }
 
@@ -851,7 +851,7 @@ bool Sdp::getOutgoingVideoSettings(map<string, string> &args) const
     if (not codec.empty()) {
         const string encoder(libav_utils::encodersMap()[codec]);
         if (encoder.empty()) {
-            DEBUG("Couldn't find encoder for \"%s\"\n", codec.c_str());
+            SFL_DBG("Couldn't find encoder for \"%s\"\n", codec.c_str());
             return false;
         } else {
             args["codec"] = encoder;
diff --git a/daemon/src/sip/sip_utils.cpp b/daemon/src/sip/sip_utils.cpp
index fc50c9efc1f6384b0677217ea66c24675336247e..b0b66a155afeb326865b9a8d048628d4f6137a0e 100644
--- a/daemon/src/sip/sip_utils.cpp
+++ b/daemon/src/sip/sip_utils.cpp
@@ -91,7 +91,7 @@ sip_utils::createRouteSet(const std::string &route, pj_pool_t *hdr_pool)
     pj_strdup2(hdr_pool, &url->host, host.c_str());
     url->port = port;
 
-    DEBUG("Adding route %s", host.c_str());
+    SFL_DBG("Adding route %s", host.c_str());
     pj_list_push_back(route_set, pjsip_hdr_clone(hdr_pool, routing));
 
     return route_set;
@@ -206,5 +206,5 @@ sip_utils::sip_strerror(pj_status_t code)
 {
     char err_msg[PJ_ERR_MSG_SIZE];
     pj_strerror(code, err_msg, sizeof err_msg);
-    ERROR("%d: %s", code, err_msg);
+    SFL_ERR("%d: %s", code, err_msg);
 }
diff --git a/daemon/src/sip/sipaccount.cpp b/daemon/src/sip/sipaccount.cpp
index 6c316d3a9ccb668b34e030513bed61ddf8d6344a..5de83548716793c4800655bbb50a5a91838a68fe 100644
--- a/daemon/src/sip/sipaccount.cpp
+++ b/daemon/src/sip/sipaccount.cpp
@@ -118,13 +118,13 @@ static void
 registration_cb(pjsip_regc_cbparam *param)
 {
     if (!param) {
-        ERROR("registration callback parameter is null");
+        SFL_ERR("registration callback parameter is null");
         return;
     }
 
     auto account = static_cast<SIPAccount *>(param->token);
     if (!account) {
-        ERROR("account doesn't exist in registration callback");
+        SFL_ERR("account doesn't exist in registration callback");
         return;
     }
 
@@ -226,7 +226,7 @@ SIPAccount::newOutgoingCall(const std::string& id, const std::string& toUrl)
         setTransport(t);
         call->setTransport(t);
 
-        DEBUG("New %s IP to IP call to %s", ipv6?"IPv6":"IPv4", to.c_str());
+        SFL_DBG("New %s IP to IP call to %s", ipv6?"IPv6":"IPv4", to.c_str());
     }
     else {
         to = toUrl;
@@ -242,7 +242,7 @@ SIPAccount::newOutgoingCall(const std::string& id, const std::string& toUrl)
         // FIXME : for now, use the same address family as the SIP transport
         family = pjsip_transport_type_get_af(getTransportType());
 
-        DEBUG("UserAgent: New registered account call to %s", toUrl.c_str());
+        SFL_DBG("UserAgent: New registered account call to %s", toUrl.c_str());
     }
 
     call->setIPToIP(isIP2IP());
@@ -314,19 +314,19 @@ SIPAccount::SIPStartCall(std::shared_ptr<SIPCall>& call)
 
     auto transport = call->getTransport();
     if (!transport) {
-        ERROR("Unable to start call without transport");
+        SFL_ERR("Unable to start call without transport");
         return false;
     }
 
     pj_str_t pjContact = getContactHeader(transport->get());
     const std::string debugContactHeader(pj_strbuf(&pjContact), pj_strlen(&pjContact));
-    DEBUG("contact header: %s / %s -> %s",
+    SFL_DBG("contact header: %s / %s -> %s",
           debugContactHeader.c_str(), from.c_str(), toUri.c_str());
 
     pjsip_dialog *dialog = NULL;
 
     if (pjsip_dlg_create_uac(pjsip_ua_instance(), &pjFrom, &pjContact, &pjTo, NULL, &dialog) != PJ_SUCCESS) {
-        ERROR("Unable to create SIP dialogs for user agent client when "
+        SFL_ERR("Unable to create SIP dialogs for user agent client when "
               "calling %s", toUri.c_str());
         return false;
     }
@@ -338,12 +338,12 @@ SIPAccount::SIPStartCall(std::shared_ptr<SIPCall>& call)
 
     pjsip_inv_session* inv = nullptr;
     if (pjsip_inv_create_uac(dialog, call->getLocalSDP().getLocalSdpSession(), 0, &inv) != PJ_SUCCESS) {
-        ERROR("Unable to create invite session for user agent client");
+        SFL_ERR("Unable to create invite session for user agent client");
         return false;
     }
 
     if (!inv) {
-        ERROR("Call invite is not initialized");
+        SFL_ERR("Call invite is not initialized");
         return PJ_FALSE;
     }
 
@@ -355,7 +355,7 @@ SIPAccount::SIPStartCall(std::shared_ptr<SIPCall>& call)
         pjsip_dlg_set_route_set(dialog, sip_utils::createRouteSet(getServiceRoute(), call->inv->pool));
 
     if (hasCredentials() and pjsip_auth_clt_set_credentials(&dialog->auth_sess, getCredentialCount(), getCredInfo()) != PJ_SUCCESS) {
-        ERROR("Could not initialize credentials for invite session authentication");
+        SFL_ERR("Could not initialize credentials for invite session authentication");
         return false;
     }
 
@@ -364,19 +364,19 @@ SIPAccount::SIPStartCall(std::shared_ptr<SIPCall>& call)
     pjsip_tx_data *tdata;
 
     if (pjsip_inv_invite(call->inv.get(), &tdata) != PJ_SUCCESS) {
-        ERROR("Could not initialize invite messager for this call");
+        SFL_ERR("Could not initialize invite messager for this call");
         return false;
     }
 
     const pjsip_tpselector tp_sel = SipTransportBroker::getTransportSelector(transport->get());
     if (pjsip_dlg_set_transport(dialog, &tp_sel) != PJ_SUCCESS) {
-        ERROR("Unable to associate transport for invite session dialog");
+        SFL_ERR("Unable to associate transport for invite session dialog");
         return false;
     }
 
     if (pjsip_inv_send_msg(call->inv.get(), tdata) != PJ_SUCCESS) {
         call->inv.reset();
-        ERROR("Unable to send invite message for this call");
+        SFL_ERR("Unable to send invite message for this call");
         return false;
     }
 
@@ -463,7 +463,7 @@ validate(std::string &member, const std::string &param, const T& valid)
     if (find(begin, end, param) != end)
         member = param;
     else
-        ERROR("Invalid parameter \"%s\"", param.c_str());
+        SFL_ERR("Invalid parameter \"%s\"", param.c_str());
 }
 
 void SIPAccount::unserialize(const YAML::Node &node)
@@ -552,7 +552,7 @@ parseInt(const std::map<std::string, std::string> &details, const char *key, T &
 {
     const auto iter = details.find(key);
     if (iter == details.end()) {
-        ERROR("Couldn't find key %s", key);
+        SFL_ERR("Couldn't find key %s", key);
         return;
     }
     i = atoi(iter->second.c_str());
@@ -618,7 +618,7 @@ void SIPAccount::setAccountDetails(const std::map<std::string, std::string> &det
         validate(srtpKeyExchange_, iter->second, VALID_SRTP_KEY_EXCHANGES);
 
     if (credentials_.empty()) { // credentials not set, construct 1 entry
-        WARN("No credentials set, inferring them...");
+        SFL_WARN("No credentials set, inferring them...");
         std::vector<std::map<std::string, std::string> > v;
         std::map<std::string, std::string> map;
         map[CONFIG_ACCOUNT_USERNAME] = username_;
@@ -747,23 +747,23 @@ std::map<std::string, std::string> SIPAccount::getVolatileAccountDetails() const
 void SIPAccount::doRegister()
 {
     if (not isEnabled()) {
-        WARN("Account must be enabled to register, ignoring");
+        SFL_WARN("Account must be enabled to register, ignoring");
         return;
     }
 
     if (hostname_.length() >= PJ_MAX_HOSTNAME)
         return;
 
-    DEBUG("doRegister %s ", hostname_.c_str());
+    SFL_DBG("doRegister %s ", hostname_.c_str());
 
     auto IPs = ip_utils::getAddrList(hostname_);
     for (const auto& ip : IPs)
-        DEBUG("--- %s ", ip.toString().c_str());
+        SFL_DBG("--- %s ", ip.toString().c_str());
 
     bool IPv6 = false;
 #if HAVE_IPV6
     if (isIP2IP()) {
-        DEBUG("doRegister isIP2IP.");
+        SFL_DBG("doRegister isIP2IP.");
         IPv6 = ip_utils::getInterfaceAddr(interface_).isIpv6();
     } else if (!IPs.empty())
         IPv6 = IPs[0].isIpv6();
@@ -772,7 +772,7 @@ void SIPAccount::doRegister()
 #if HAVE_TLS
     // Init TLS settings if the user wants to use TLS
     if (tlsEnable_) {
-        DEBUG("TLS is enabled for account %s", accountID_.c_str());
+        SFL_DBG("TLS is enabled for account %s", accountID_.c_str());
 
         // Dropping current calls already using the transport is currently required
         // with TLS.
@@ -787,7 +787,7 @@ void SIPAccount::doRegister()
                 getTlsSetting());
             if (!tlsListener_) {
                 setRegistrationState(RegistrationState::ERROR_GENERIC);
-                ERROR("Error creating TLS listener.");
+                SFL_ERR("Error creating TLS listener.");
                 return;
             }
         }
@@ -818,7 +818,7 @@ void SIPAccount::doRegister()
     }
 
     try {
-        WARN("Creating transport");
+        SFL_WARN("Creating transport");
         transport_.reset();
 #if HAVE_TLS
         if (isTlsEnabled()) {
@@ -835,7 +835,7 @@ void SIPAccount::doRegister()
 
         sendRegister();
     } catch (const VoipLinkException &e) {
-        ERROR("%s", e.what());
+        SFL_ERR("%s", e.what());
         setRegistrationState(RegistrationState::ERROR_GENERIC);
         return;
     }
@@ -860,7 +860,7 @@ void SIPAccount::doUnregister(std::function<void(bool)> released_cb)
     try {
         sendUnregister();
     } catch (const VoipLinkException &e) {
-        ERROR("doUnregister %s", e.what());
+        SFL_ERR("doUnregister %s", e.what());
     }
 
     // remove the transport from the account
@@ -881,7 +881,7 @@ void SIPAccount::startKeepAliveTimer()
     if (keepAliveTimerActive_)
         return;
 
-    DEBUG("Start keep alive timer for account %s", getAccountID().c_str());
+    SFL_DBG("Start keep alive timer for account %s", getAccountID().c_str());
 
     // make sure here we have an entirely new timer
     memset(&keepAliveTimer_, 0, sizeof(pj_timer_entry));
@@ -893,10 +893,10 @@ void SIPAccount::startKeepAliveTimer()
 
     // expiration may be undetermined during the first registration request
     if (registrationExpire_ == 0) {
-        DEBUG("Registration Expire: 0, taking 60 instead");
+        SFL_DBG("Registration Expire: 0, taking 60 instead");
         keepAliveDelay_.sec = 3600;
     } else {
-        DEBUG("Registration Expire: %d", registrationExpire_);
+        SFL_DBG("Registration Expire: %d", registrationExpire_);
         keepAliveDelay_.sec = registrationExpire_ + MIN_REGISTRATION_TIME;
     }
 
@@ -910,7 +910,7 @@ void SIPAccount::startKeepAliveTimer()
 void SIPAccount::stopKeepAliveTimer()
 {
     if (keepAliveTimerActive_) {
-        DEBUG("Stop keep alive timer %d for account %s", keepAliveTimer_.id, getAccountID().c_str());
+        SFL_DBG("Stop keep alive timer %d for account %s", keepAliveTimer_.id, getAccountID().c_str());
         keepAliveTimerActive_ = false;
         link_->cancelKeepAliveTimer(keepAliveTimer_);
     }
@@ -920,7 +920,7 @@ void
 SIPAccount::sendRegister()
 {
     if (not isEnabled()) {
-        WARN("Account must be enabled to register, ignoring");
+        SFL_WARN("Account must be enabled to register, ignoring");
         return;
     }
 
@@ -947,7 +947,7 @@ SIPAccount::sendRegister()
     if (transport_) {
         if (not getPublishedSameasLocal() or (not received.empty() and received != getPublishedAddress())) {
             pjsip_host_port *via = getViaAddr();
-            DEBUG("Setting VIA sent-by to %.*s:%d", via->host.slen, via->host.ptr, via->port);
+            SFL_DBG("Setting VIA sent-by to %.*s:%d", via->host.slen, via->host.ptr, via->port);
 
             if (pjsip_regc_set_via_sent_by(regc, via, transport_->get()) != PJ_SUCCESS)
                 throw VoipLinkException("Unable to set the \"sent-by\" field");
@@ -959,7 +959,7 @@ SIPAccount::sendRegister()
 
     pj_status_t status;
 
-    //DEBUG("pjsip_regc_init from:%s, srv:%s, contact:%s", from.c_str(), srvUri.c_str(), std::string(pj_strbuf(&pjContact), pj_strlen(&pjContact)).c_str());
+    //SFL_DBG("pjsip_regc_init from:%s, srv:%s, contact:%s", from.c_str(), srvUri.c_str(), std::string(pj_strbuf(&pjContact), pj_strlen(&pjContact)).c_str());
     if ((status = pjsip_regc_init(regc, &pjSrv, &pjFrom, &pjFrom, 1, &pjContact, getRegistrationExpire())) != PJ_SUCCESS) {
         sip_utils::sip_strerror(status);
         throw VoipLinkException("Unable to initialize account registration structure");
@@ -1004,11 +1004,11 @@ SIPAccount::onRegister(pjsip_regc_cbparam *param)
         return;
 
     if (param->status != PJ_SUCCESS) {
-        ERROR("SIP registration error %d", param->status);
+        SFL_ERR("SIP registration error %d", param->status);
         destroyRegistrationInfo();
         stopKeepAliveTimer();
     } else if (param->code < 0 || param->code >= 300) {
-        ERROR("SIP registration failed, status=%d (%.*s)",
+        SFL_ERR("SIP registration failed, status=%d (%.*s)",
               param->code, (int)param->reason.slen, param->reason.ptr);
         destroyRegistrationInfo();
         stopKeepAliveTimer();
@@ -1037,7 +1037,7 @@ SIPAccount::onRegister(pjsip_regc_cbparam *param)
             destroyRegistrationInfo();
             /* Stop keep-alive timer if any. */
             stopKeepAliveTimer();
-            DEBUG("Unregistration success");
+            SFL_DBG("Unregistration success");
             setRegistrationState(RegistrationState::UNREGISTERED);
         } else {
             /* TODO Check and update SIP outbound status first, since the result
@@ -1046,7 +1046,7 @@ SIPAccount::onRegister(pjsip_regc_cbparam *param)
             // update_rfc5626_status(acc, param->rdata);
 
             if (checkNATAddress(param, link_->getPool()))
-                WARN("Contact overwritten");
+                SFL_WARN("Contact overwritten");
 
             /* TODO Check and update Service-Route header */
             if (hasServiceRoute())
@@ -1167,7 +1167,7 @@ void SIPAccount::initTlsConfiguration()
     CipherArray avail_ciphers(256);
     unsigned cipherNum = avail_ciphers.size();
     if (pj_ssl_cipher_get_availables(&avail_ciphers.front(), &cipherNum) != PJ_SUCCESS)
-        ERROR("Could not determine cipher list on this system");
+        SFL_ERR("Could not determine cipher list on this system");
     avail_ciphers.resize(cipherNum);
 
     ciphers_.clear();
@@ -1179,11 +1179,11 @@ void SIPAccount::initTlsConfiguration()
             if (item.empty()) continue;
             auto item_cid = pj_ssl_cipher_id(item.c_str());
             if (item_cid != PJ_TLS_UNKNOWN_CIPHER) {
-                WARN("Valid cipher: %s", item.c_str());
+                SFL_WARN("Valid cipher: %s", item.c_str());
                 ciphers_.push_back(item_cid);
             }
             else
-                ERROR("Invalid cipher: %s", item.c_str());
+                SFL_ERR("Invalid cipher: %s", item.c_str());
         }
     }
 #endif
@@ -1203,7 +1203,7 @@ void SIPAccount::initTlsConfiguration()
     pj_cstr(&tlsSetting_.privkey_file, tlsPrivateKeyFile_.c_str());
     pj_cstr(&tlsSetting_.password, tlsPassword_.c_str());
 
-    DEBUG("Using %u ciphers", ciphers_.size());
+    SFL_DBG("Using %u ciphers", ciphers_.size());
     tlsSetting_.ciphers_num = ciphers_.size();
     tlsSetting_.ciphers = &ciphers_.front();
 
@@ -1380,7 +1380,7 @@ SIPAccount::getContactHeader(pjsip_transport* t)
     if (!t && transport_)
         t = transport_->get();
     if (!t)
-        ERROR("Transport not created yet");
+        SFL_ERR("Transport not created yet");
 
     if (contact_.slen and contactOverwritten_)
         return contact_;
@@ -1404,7 +1404,7 @@ SIPAccount::getContactHeader(pjsip_transport* t)
     if (not publishedSameasLocal_) {
         address = publishedIpAddress_;
         port = publishedPort_;
-        DEBUG("Using published address %s and port %d", address.c_str(), port);
+        SFL_DBG("Using published address %s and port %d", address.c_str(), port);
     } else if (stunEnabled_) {
         link_->sipTransport->findLocalAddressFromSTUN(
             t,
@@ -1417,12 +1417,12 @@ SIPAccount::getContactHeader(pjsip_transport* t)
     } else {
         if (!receivedParameter_.empty()) {
             address = receivedParameter_;
-            DEBUG("Using received address %s", address.c_str());
+            SFL_DBG("Using received address %s", address.c_str());
         }
 
         if (rPort_ != -1 and rPort_ != 0) {
             port = rPort_;
-            DEBUG("Using received port %d", port);
+            SFL_DBG("Using received port %d", port);
         }
     }
 
@@ -1478,11 +1478,11 @@ void SIPAccount::keepAliveRegistrationCb(UNUSED pj_timer_heap_t *th, pj_timer_en
     SIPAccount *sipAccount = static_cast<SIPAccount *>(te->user_data);
 
     if (sipAccount == nullptr) {
-        ERROR("SIP account is nullptr while registering a new keep alive timer");
+        SFL_ERR("SIP account is nullptr while registering a new keep alive timer");
         return;
     }
 
-    ERROR("Keep alive registration callback for account %s", sipAccount->getAccountID().c_str());
+    SFL_ERR("Keep alive registration callback for account %s", sipAccount->getAccountID().c_str());
 
     // IP2IP default does not require keep-alive
     if (sipAccount->isIP2IP())
@@ -1541,7 +1541,7 @@ void SIPAccount::setCredentials(const std::vector<std::map<std::string, std::str
 {
     // we can not authenticate without credentials
     if (creds.empty()) {
-        ERROR("Cannot authenticate with empty credentials list");
+        SFL_ERR("Cannot authenticate with empty credentials list");
         return;
     }
 
@@ -1729,11 +1729,11 @@ void
 SIPAccount::enablePresence(const bool& enabled)
 {
     if (!presence_) {
-        ERROR("Presence not initialized");
+        SFL_ERR("Presence not initialized");
         return;
     }
 
-    DEBUG("Presence enabled for %s : %s.",
+    SFL_DBG("Presence enabled for %s : %s.",
           accountID_.c_str(),
           enabled? TRUE_STR : FALSE_STR);
 
@@ -1748,14 +1748,14 @@ void
 SIPAccount::supportPresence(int function, bool enabled)
 {
     if (!presence_) {
-        ERROR("Presence not initialized");
+        SFL_ERR("Presence not initialized");
         return;
     }
 
     if (presence_->isSupported(function) == enabled)
         return;
 
-    DEBUG("Presence support for %s (%s: %s).", accountID_.c_str(),
+    SFL_DBG("Presence support for %s (%s: %s).", accountID_.c_str(),
           function == PRESENCE_FUNCTION_PUBLISH ? "publish" : "subscribe",
           enabled ? TRUE_STR : FALSE_STR);
     presence_->support(function, enabled);
@@ -1775,16 +1775,16 @@ SIPAccount::matches(const std::string &userName, const std::string &server,
                     pjsip_endpoint *endpt, pj_pool_t *pool) const
 {
     if (fullMatch(userName, server, endpt, pool)) {
-        DEBUG("Matching account id in request is a fullmatch %s@%s", userName.c_str(), server.c_str());
+        SFL_DBG("Matching account id in request is a fullmatch %s@%s", userName.c_str(), server.c_str());
         return MatchRank::FULL;
     } else if (hostnameMatch(server, endpt, pool)) {
-        DEBUG("Matching account id in request with hostname %s", server.c_str());
+        SFL_DBG("Matching account id in request with hostname %s", server.c_str());
         return MatchRank::PARTIAL;
     } else if (userMatch(userName)) {
-        DEBUG("Matching account id in request with username %s", userName.c_str());
+        SFL_DBG("Matching account id in request with username %s", userName.c_str());
         return MatchRank::PARTIAL;
     } else if (proxyMatch(server, endpt, pool)) {
-        DEBUG("Matching account id in request with proxy %s", server.c_str());
+        SFL_DBG("Matching account id in request with proxy %s", server.c_str());
         return MatchRank::PARTIAL;
     } else {
         return MatchRank::NONE;
@@ -1923,7 +1923,7 @@ SIPAccount::checkNATAddress(pjsip_regc_cbparam *param, pj_pool_t *pool)
         via_addrstr = IpAddr(via_addrstr).toString(false, true);
 #endif
 
-    WARN("IP address change detected for account %s "
+    SFL_WARN("IP address change detected for account %s "
          "(%.*s:%d --> %s:%d). Updating registration "
          "(using method %d)",
          accountID_.c_str(),
@@ -1973,7 +1973,7 @@ SIPAccount::checkNATAddress(pjsip_regc_cbparam *param, pj_pool_t *pool)
                 rport,
                 transport_param);
         if (len < 1) {
-            ERROR("URI too long");
+            SFL_ERR("URI too long");
             return false;
         }
 
@@ -1989,7 +1989,7 @@ SIPAccount::checkNATAddress(pjsip_regc_cbparam *param, pj_pool_t *pool)
             tmp_tp = transport_;
             sendUnregister();
         } catch (const VoipLinkException &e) {
-            ERROR("%s", e.what());
+            SFL_ERR("%s", e.what());
         }
 
         pjsip_regc_update_contact(regc_, 1, &contact_);
@@ -1998,7 +1998,7 @@ SIPAccount::checkNATAddress(pjsip_regc_cbparam *param, pj_pool_t *pool)
         try {
             sendRegister();
         } catch (const VoipLinkException &e) {
-            ERROR("%s", e.what());
+            SFL_ERR("%s", e.what());
         }
     }
 
@@ -2027,7 +2027,7 @@ SIPAccount::autoReregTimerCb(pj_timer_heap_t * /*th*/, pj_timer_entry *te)
     try {
         acc->sendRegister();
     } catch (const VoipLinkException &e) {
-        ERROR("%s", e.what());
+        SFL_ERR("%s", e.what());
         acc->scheduleReregistration(endpt);
     }
     delete context;
@@ -2073,7 +2073,7 @@ SIPAccount::scheduleReregistration(pjsip_endpoint *endpt)
 
     pj_time_val_normalize(&delay);
 
-    WARN("Scheduling re-registration retry in %u seconds..", delay.sec);
+    SFL_WARN("Scheduling re-registration retry in %u seconds..", delay.sec);
     auto_rereg_.timer.id = PJ_TRUE;
     if (pjsip_endpt_schedule_timer(endpt, &auto_rereg_.timer, &delay) != PJ_SUCCESS)
         auto_rereg_.timer.id = PJ_FALSE;
diff --git a/daemon/src/sip/sipaccountbase.cpp b/daemon/src/sip/sipaccountbase.cpp
index ed763f537165ff2f8411db38f2a580498c7b8969..e67a9bca04ea7408572867b78593f1894e926db5 100644
--- a/daemon/src/sip/sipaccountbase.cpp
+++ b/daemon/src/sip/sipaccountbase.cpp
@@ -57,7 +57,7 @@ validate(std::string &member, const std::string &param, const T& valid)
     if (find(begin, end, param) != end)
         member = param;
     else
-        ERROR("Invalid parameter \"%s\"", param.c_str());
+        SFL_ERR("Invalid parameter \"%s\"", param.c_str());
 }
 
 static void
@@ -85,7 +85,7 @@ parseInt(const std::map<std::string, std::string> &details, const char *key, T &
 {
     const auto iter = details.find(key);
     if (iter == details.end()) {
-        ERROR("Couldn't find key %s", key);
+        SFL_ERR("Couldn't find key %s", key);
         return;
     }
     i = atoi(iter->second.c_str());
@@ -131,7 +131,7 @@ void SIPAccountBase::unserialize(const YAML::Node &node)
 #ifdef SFL_VIDEO
     if (tmp.empty()) {
         // Video codecs are an empty list
-        WARN("Loading default video codecs");
+        SFL_WARN("Loading default video codecs");
         tmp = libav_utils::getDefaultCodecs();
     }
 #endif
@@ -241,7 +241,7 @@ void
 SIPAccountBase::onTransportStateChanged(pjsip_transport_state state, const pjsip_transport_state_info *info)
 {
     pj_status_t currentStatus = transportStatus_;
-    DEBUG("Transport state changed to %s for account %s !", SipTransport::stateToStr(state), accountID_.c_str());
+    SFL_DBG("Transport state changed to %s for account %s !", SipTransport::stateToStr(state), accountID_.c_str());
     if (!SipTransport::isAlive(transport_, state)) {
         if (info) {
             char err_msg[128];
@@ -249,7 +249,7 @@ SIPAccountBase::onTransportStateChanged(pjsip_transport_state state, const pjsip
             pj_str_t descr = pj_strerror(info->status, err_msg, sizeof(err_msg));
             transportStatus_ = info ? info->status : PJSIP_SC_OK;
             transportError_  = std::string(descr.ptr, descr.slen);
-            ERROR("Transport disconnected: %.*s", descr.slen, descr.ptr);
+            SFL_ERR("Transport disconnected: %.*s", descr.slen, descr.ptr);
         }
         else {
             // This is already the generic error used by pjsip.
@@ -277,7 +277,7 @@ SIPAccountBase::setTransport(const std::shared_ptr<SipTransport>& t)
     if (t == transport_)
         return;
     if (transport_) {
-        DEBUG("Removing transport from account");
+        SFL_DBG("Removing transport from account");
         transport_->removeStateListener(reinterpret_cast<uintptr_t>(this));
     }
 
diff --git a/daemon/src/sip/sipcall.cpp b/daemon/src/sip/sipcall.cpp
index 8d1ec2bc27536282b43a4506e2f480b09f76fa21..1a573f2705e4b6ecef47487d27a26e874eed19c6 100644
--- a/daemon/src/sip/sipcall.cpp
+++ b/daemon/src/sip/sipcall.cpp
@@ -76,7 +76,7 @@ dtmfSend(SIPCall &call, char code, const std::string &dtmf)
         call.getAudioRtp().sendDtmfDigit(code);
         return;
     } else if (dtmf != SIPAccount::SIPINFO_STR) {
-        WARN("Unknown DTMF type %s, defaulting to %s instead",
+        SFL_WARN("Unknown DTMF type %s, defaulting to %s instead",
              dtmf.c_str(), SIPAccount::SIPINFO_STR);
     } // else : dtmf == SIPINFO
 
@@ -115,9 +115,9 @@ SIPCall::~SIPCall()
     const auto mod_ua_id = getSIPVoIPLink()->getModId();
 
     // prevent this from getting accessed in callbacks
-    // WARN: this is not thread-safe!
+    // SFL_WARN: this is not thread-safe!
     if (inv && inv->mod_data[mod_ua_id]) {
-        WARN("Call was not properly removed from invite callbacks");
+        SFL_WARN("Call was not properly removed from invite callbacks");
         inv->mod_data[mod_ua_id] = nullptr;
     }
 
@@ -213,7 +213,7 @@ SIPCall::sendSIPInfo(const char *const body, const char *const subtype)
     if (not inv or not inv->dlg)
         throw VoipLinkException("Couldn't get invite dialog");
 
-    pj_str_t methodName = CONST_PJ_STR("INFO");
+    pj_str_t methodName = CONST_PJ_STR("SFL_INFO");
     pjsip_method method;
     pjsip_method_init_np(&method, &methodName);
 
@@ -221,7 +221,7 @@ SIPCall::sendSIPInfo(const char *const body, const char *const subtype)
     pjsip_tx_data *tdata;
 
     if (pjsip_dlg_create_request(inv->dlg, &method, -1, &tdata) != PJ_SUCCESS) {
-        ERROR("Could not create dialog");
+        SFL_ERR("Could not create dialog");
         return;
     }
 
@@ -256,7 +256,7 @@ SIPCall::updateSDPFromSTUN()
         local_sdp_->setPublishedIP(account.getPublishedAddress());
         local_sdp_->updatePorts(stunPorts);
     } catch (const std::runtime_error &e) {
-        ERROR("%s", e.what());
+        SFL_ERR("%s", e.what());
     }
 }
 
@@ -268,7 +268,7 @@ void SIPCall::answer()
         throw VoipLinkException("No invite session for this call");
 
     if (!inv->neg) {
-        WARN("Negotiator is NULL, we've received an INVITE without an SDP");
+        SFL_WARN("Negotiator is NULL, we've received an INVITE without an SDP");
         pjmedia_sdp_session *dummy = 0;
         getSIPVoIPLink()->createSDPOffer(inv.get(), &dummy);
 
@@ -289,7 +289,7 @@ void SIPCall::answer()
 
     // contactStr must stay in scope as long as tdata
     if (contactHeader_.slen) {
-        DEBUG("Answering with contact header: %.*s", contactHeader_.slen, contactHeader_.ptr);
+        SFL_DBG("Answering with contact header: %.*s", contactHeader_.slen, contactHeader_.ptr);
         sip_utils::addContactHeader(&contactHeader_, tdata);
     }
 
@@ -317,7 +317,7 @@ SIPCall::hangup(int reason)
 
         if (printed >= 0) {
             buf[printed] = '\0';
-            DEBUG("Route header %s", buf);
+            SFL_DBG("Route header %s", buf);
         }
 
         route = route->next;
@@ -508,7 +508,7 @@ SIPCall::transfer(const std::string& to)
 
     toUri = account.getToUri(to);
     pj_cstr(&dst, toUri.c_str());
-    DEBUG("Transferring to %.*s", dst.slen, dst.ptr);
+    SFL_DBG("Transferring to %.*s", dst.slen, dst.ptr);
 
     if (!transferCommon(&dst))
         throw VoipLinkException("Couldn't transfer");
@@ -570,7 +570,7 @@ SIPCall::onhold()
 #endif
 
     if (SIPSessionReinvite() != PJ_SUCCESS)
-        WARN("Reinvite failed");
+        SFL_WARN("Reinvite failed");
 }
 
 void
@@ -585,7 +585,7 @@ SIPCall::offhold()
             internalOffHold([] {});
 
     } catch (const SdpException &e) {
-        ERROR("%s", e.what());
+        SFL_ERR("%s", e.what());
         throw VoipLinkException("SDP issue in offhold");
     } catch (const ost::Socket::Error &e) {
         throw VoipLinkException("Socket problem in offhold");
@@ -605,7 +605,7 @@ SIPCall::internalOffHold(const std::function<void()> &SDPUpdateFunc)
     std::vector<sfl::AudioCodec*> sessionMedia(local_sdp_->getSessionAudioMedia());
 
     if (sessionMedia.empty()) {
-        WARN("Session media is empty");
+        SFL_WARN("Session media is empty");
         return;
     }
 
@@ -620,7 +620,7 @@ SIPCall::internalOffHold(const std::function<void()> &SDPUpdateFunc)
         sfl::AudioCodec* ac = Manager::instance().audioCodecFactory.instantiateCodec(i->getPayloadType());
 
         if (ac == NULL) {
-            ERROR("Could not instantiate codec %d", i->getPayloadType());
+            SFL_ERR("Could not instantiate codec %d", i->getPayloadType());
             throw std::runtime_error("Could not instantiate codec");
         }
 
@@ -653,7 +653,7 @@ SIPCall::internalOffHold(const std::function<void()> &SDPUpdateFunc)
 #endif
 
     if (SIPSessionReinvite() != PJ_SUCCESS) {
-        WARN("Reinvite failed, resuming hold");
+        SFL_WARN("Reinvite failed, resuming hold");
         onhold();
     }
 }
diff --git a/daemon/src/sip/sippresence.cpp b/daemon/src/sip/sippresence.cpp
index bdca3b89dd315595682a69af8a713cef47c2d3ff..105885844b757cc0953a66a40d7f3cd02c37443c 100644
--- a/daemon/src/sip/sippresence.cpp
+++ b/daemon/src/sip/sippresence.cpp
@@ -93,7 +93,7 @@ SIPPresence::~SIPPresence()
     sub_server_list_.clear();
 
     if (mutex_ and pj_mutex_destroy(mutex_) != PJ_SUCCESS)
-        ERROR("Error destroying mutex");
+        SFL_ERR("Error destroying mutex");
 
     pj_pool_release(pool_);
     pj_caching_pool_destroy(&cp_);
@@ -160,7 +160,7 @@ void SIPPresence::updateStatus(bool status, const std::string &note)
         rpid.activity = PJRPID_ACTIVITY_BUSY;
     /*
     else // TODO: is there any other possibilities
-        DEBUG("Presence : no activity");
+        SFL_DBG("Presence : no activity");
     */
 
     pj_bzero(&status_data_, sizeof(status_data_));
@@ -196,7 +196,7 @@ void SIPPresence::reportPresSubClientNotification(const std::string& uri, pjsip_
     const std::string acc_ID = acc_->getAccountID();
     const std::string basic(status->info[0].basic_open ? "open" : "closed");
     const std::string note(status->info[0].rpid.note.ptr, status->info[0].rpid.note.slen);
-    DEBUG(" Received status of PresSubClient  %s(acc:%s): status=%s note=%s", uri.c_str(), acc_ID.c_str(), basic.c_str(), note.c_str());
+    SFL_DBG(" Received status of PresSubClient  %s(acc:%s): status=%s note=%s", uri.c_str(), acc_ID.c_str(), basic.c_str(), note.c_str());
 
     if (uri == acc_->getFromUri()) {
         // save the status of our own account
@@ -222,7 +222,7 @@ void SIPPresence::subscribeClient(const std::string& uri, bool flag)
     /* Check if the buddy was already subscribed */
     for (const auto & c : sub_client_list_) {
         if (c->getURI() == uri) {
-            //DEBUG("-PresSubClient:%s exists in the list. Replace it.", uri.c_str());
+            //SFL_DBG("-PresSubClient:%s exists in the list. Replace it.", uri.c_str());
             if (flag)
                 c->subscribe();
             else
@@ -232,14 +232,14 @@ void SIPPresence::subscribeClient(const std::string& uri, bool flag)
     }
 
     if (sub_client_list_.size() >= MAX_N_SUB_CLIENT) {
-        WARN("Can't add PresSubClient, max number reached.");
+        SFL_WARN("Can't add PresSubClient, max number reached.");
         return;
     }
 
     if (flag) {
         PresSubClient *c = new PresSubClient(uri, this);
         if (!(c->subscribe())) {
-            WARN("Failed send subscribe.");
+            SFL_WARN("Failed send subscribe.");
             delete c;
         }
         // the buddy has to be accepted before being added in the list
@@ -250,16 +250,16 @@ void SIPPresence::addPresSubClient(PresSubClient *c)
 {
     if (sub_client_list_.size() < MAX_N_SUB_CLIENT) {
         sub_client_list_.push_back(c);
-        DEBUG("New Presence_subscription_client added (list[%i]).", sub_client_list_.size());
+        SFL_DBG("New Presence_subscription_client added (list[%i]).", sub_client_list_.size());
     } else {
-        WARN("Max Presence_subscription_client is reach.");
+        SFL_WARN("Max Presence_subscription_client is reach.");
         // let the client alive //delete c;
     }
 }
 
 void SIPPresence::removePresSubClient(PresSubClient *c)
 {
-    DEBUG("Remove Presence_subscription_client from the buddy list.");
+    SFL_DBG("Remove Presence_subscription_client from the buddy list.");
     sub_client_list_.remove(c);
 }
 
@@ -279,7 +279,7 @@ void SIPPresence::addPresSubServer(PresSubServer *s)
     if (sub_server_list_.size() < MAX_N_SUB_SERVER) {
         sub_server_list_.push_back(s);
     } else {
-        WARN("Max Presence_subscription_server is reach.");
+        SFL_WARN("Max Presence_subscription_server is reach.");
         // let de server alive // delete s;
     }
 }
@@ -287,12 +287,12 @@ void SIPPresence::addPresSubServer(PresSubServer *s)
 void SIPPresence::removePresSubServer(PresSubServer *s)
 {
     sub_server_list_.remove(s);
-    DEBUG("Presence_subscription_server removed");
+    SFL_DBG("Presence_subscription_server removed");
 }
 
 void SIPPresence::notifyPresSubServer()
 {
-    DEBUG("Iterating through IP2IP Presence_subscription_server:");
+    SFL_DBG("Iterating through IP2IP Presence_subscription_server:");
 
     for (const auto & s : sub_server_list_)
         s->notify();
@@ -344,7 +344,7 @@ void SIPPresence::fillDoc(pjsip_tx_data *tdata, const pres_msg_data *msg_data)
     while (hdr && hdr != &msg_data->hdr_list) {
         pjsip_hdr *new_hdr;
         new_hdr = (pjsip_hdr*) pjsip_hdr_clone(tdata->pool, hdr);
-        DEBUG("adding header", new_hdr->name.ptr);
+        SFL_DBG("adding header", new_hdr->name.ptr);
         pjsip_msg_add_hdr(tdata->msg, new_hdr);
         hdr = hdr->next;
     }
@@ -379,7 +379,7 @@ SIPPresence::publish_cb(struct pjsip_publishc_cbparam *param)
         if (param->status != PJ_SUCCESS) {
             char errmsg[PJ_ERR_MSG_SIZE];
             pj_strerror(param->status, errmsg, sizeof(errmsg));
-            ERROR("Client (PUBLISH) failed, status=%d, msg=%s", param->status, errmsg);
+            SFL_ERR("Client (PUBLISH) failed, status=%d, msg=%s", param->status, errmsg);
             Manager::instance().getClient()->getPresenceManager()->serverError(
                     pres->getAccount()->getAccountID(),
                     error,
@@ -389,10 +389,10 @@ SIPPresence::publish_cb(struct pjsip_publishc_cbparam *param)
             /* 412 (Conditional Request Failed)
              * The PUBLISH refresh has failed, retry with new one.
              */
-            WARN("Publish retry.");
+            SFL_WARN("Publish retry.");
             publish(pres);
         } else if ((param->code == PJSIP_SC_BAD_EVENT) || (param->code == PJSIP_SC_NOT_IMPLEMENTED)){ //489 or 501
-            WARN("Client (PUBLISH) failed (%s)",error.c_str());
+            SFL_WARN("Client (PUBLISH) failed (%s)",error.c_str());
 
             Manager::instance().getClient()->getPresenceManager()->serverError(
                     pres->getAccount()->getAccountID(),
@@ -424,7 +424,7 @@ SIPPresence::send_publish(SIPPresence * pres)
     pjsip_tx_data *tdata;
     pj_status_t status;
 
-    DEBUG("Send PUBLISH (%s).", pres->getAccount()->getAccountID().c_str());
+    SFL_DBG("Send PUBLISH (%s).", pres->getAccount()->getAccountID().c_str());
 
     SIPAccount * acc = pres->getAccount();
     std::string contactWithAngles =  acc->getFromUri();
@@ -442,7 +442,7 @@ SIPPresence::send_publish(SIPPresence * pres)
     pj_str_t from = pj_strdup3(pres->pool_, acc->getFromUri().c_str());
 
     if (status != PJ_SUCCESS) {
-        ERROR("Error creating PUBLISH request", status);
+        SFL_ERR("Error creating PUBLISH request", status);
         goto on_error;
     }
 
@@ -468,7 +468,7 @@ SIPPresence::send_publish(SIPPresence * pres)
     pres_msg_data msg_data;
 
     if (status != PJ_SUCCESS) {
-        ERROR("Error creating PIDF for PUBLISH request");
+        SFL_ERR("Error creating PIDF for PUBLISH request");
         pjsip_tx_data_dec_ref(tdata);
         goto on_error;
     }
@@ -484,9 +484,9 @@ SIPPresence::send_publish(SIPPresence * pres)
     status = pjsip_publishc_send(pres->publish_sess_, tdata);
 
     if (status == PJ_EPENDING) {
-        WARN("Previous request is in progress, ");
+        SFL_WARN("Previous request is in progress, ");
     } else if (status != PJ_SUCCESS) {
-        ERROR("Error sending PUBLISH request");
+        SFL_ERR("Error sending PUBLISH request");
         goto on_error;
     }
 
@@ -521,7 +521,7 @@ SIPPresence::publish(SIPPresence *pres)
 
     if (status != PJ_SUCCESS) {
         pres->publish_sess_ = NULL;
-        ERROR("Failed to create a publish seesion.");
+        SFL_ERR("Failed to create a publish seesion.");
         return status;
     }
 
@@ -530,14 +530,14 @@ SIPPresence::publish(SIPPresence *pres)
     status = pjsip_publishc_init(pres->publish_sess_, &STR_PRESENCE, &from, &from, &from, 0xFFFF);
 
     if (status != PJ_SUCCESS) {
-        ERROR("Failed to init a publish session");
+        SFL_ERR("Failed to init a publish session");
         pres->publish_sess_ = NULL;
         return status;
     }
 
     /* Add credential for authentication */
     if (acc->hasCredentials() and pjsip_publishc_set_credentials(pres->publish_sess_, acc->getCredentialCount(), acc->getCredInfo()) != PJ_SUCCESS) {
-        ERROR("Could not initialize credentials for invite session authentication");
+        SFL_ERR("Could not initialize credentials for invite session authentication");
         return status;
     }
 
diff --git a/daemon/src/sip/siptransport.cpp b/daemon/src/sip/siptransport.cpp
index d2ed0291b055add63bef17d991581b6c87b76c5a..b0ef2eabf94d43af778ce40663bbc8e718b7c885 100644
--- a/daemon/src/sip/siptransport.cpp
+++ b/daemon/src/sip/siptransport.cpp
@@ -53,7 +53,7 @@
 #include <sstream>
 #include <algorithm>
 
-#define RETURN_IF_FAIL(A, VAL, M, ...) if (!(A)) { ERROR(M, ##__VA_ARGS__); return (VAL); }
+#define RETURN_IF_FAIL(A, VAL, M, ...) if (!(A)) { SFL_ERR(M, ##__VA_ARGS__); return (VAL); }
 
 // FIXME: remove this when pjsip_tp_state_callback gives us enough info
 static SipTransportBroker* instance = nullptr;
@@ -82,7 +82,7 @@ SipTransport::~SipTransport()
     if (transport) {
         pjsip_transport_shutdown(transport);
         pjsip_transport_dec_ref(transport); // ??
-        DEBUG("Destroying transport (refcount: %u)",  pj_atomic_get(transport->ref_cnt));
+        SFL_DBG("Destroying transport (refcount: %u)",  pj_atomic_get(transport->ref_cnt));
         transport = nullptr;
     }
 }
@@ -114,7 +114,7 @@ cp_(cp), pool_(pool), endpt_(endpt)
     instance = this;
     auto status = pjsip_tpmgr_set_state_cb(pjsip_endpt_get_tpmgr(endpt_), SipTransportBroker::tp_state_callback);
     if (status != PJ_SUCCESS) {
-        ERROR("Can't set transport callback");
+        SFL_ERR("Can't set transport callback");
         sip_utils::sip_strerror(status);
     }
 }
@@ -130,7 +130,7 @@ void
 SipTransportBroker::tp_state_callback(pjsip_transport *tp, pjsip_transport_state state, const pjsip_transport_state_info* info)
 {
     if (!instance) {
-        ERROR("Can't bubble event: SipTransportBroker instance is null !");
+        SFL_ERR("Can't bubble event: SipTransportBroker instance is null !");
         return;
     }
     instance->transportStateChanged(tp, state, info);
@@ -139,7 +139,7 @@ SipTransportBroker::tp_state_callback(pjsip_transport *tp, pjsip_transport_state
 void
 SipTransportBroker::transportStateChanged(pjsip_transport* tp, pjsip_transport_state state, const pjsip_transport_state_info* info)
 {
-    WARN("Transport %s -> %s", tp->info, SipTransport::stateToStr(state));
+    SFL_WARN("Transport %s -> %s", tp->info, SipTransport::stateToStr(state));
     {
         std::shared_ptr<SipTransport> transport {};
         {
@@ -229,18 +229,18 @@ SipTransportBroker::getUdpTransport(const SipTransportDescr& descr)
         auto it = transports_.find(itp->second);
         if (it != transports_.end()) {
             if (auto spt = it->second.lock()) {
-                DEBUG("Reusing transport %s", descr.toString().c_str());
+                SFL_DBG("Reusing transport %s", descr.toString().c_str());
                 return spt;
             }
             else {
                 // Transport still exists but have not been destroyed yet.
-                WARN("Recycling transport %s", descr.toString().c_str());
+                SFL_WARN("Recycling transport %s", descr.toString().c_str());
                 auto ret = std::make_shared<SipTransport>(itp->second);
                 it->second = ret;
                 return ret;
             }
         } else {
-            WARN("Cleaning up UDP transport %s", descr.toString().c_str());
+            SFL_WARN("Cleaning up UDP transport %s", descr.toString().c_str());
             udpTransports_.erase(itp);
         }
     }
@@ -269,14 +269,14 @@ SipTransportBroker::createUdpTransport(const SipTransportDescr& d)
         ? pjsip_udp_transport_start (endpt_, &static_cast<const pj_sockaddr_in&>(listeningAddress),  nullptr, 1, &transport)
         : pjsip_udp_transport_start6(endpt_, &static_cast<const pj_sockaddr_in6&>(listeningAddress), nullptr, 1, &transport);
     if (status != PJ_SUCCESS) {
-        ERROR("UDP IPv%s Transport did not start on %s",
+        SFL_ERR("UDP IPv%s Transport did not start on %s",
             listeningAddress.isIpv4() ? "4" : "6",
             listeningAddress.toString(true).c_str());
         sip_utils::sip_strerror(status);
         return nullptr;
     }
 
-    DEBUG("Created UDP transport on %s : %s", d.interface.c_str(), listeningAddress.toString(true).c_str());
+    SFL_DBG("Created UDP transport on %s : %s", d.interface.c_str(), listeningAddress.toString(true).c_str());
     auto ret = std::make_shared<SipTransport>(transport);
     // dec ref because the refcount starts at 1 and SipTransport increments it ?
     // pjsip_transport_dec_ref(transport);
@@ -296,19 +296,19 @@ SipTransportBroker::getTlsListener(const SipTransportDescr& d, const pjsip_tls_s
     listeningAddress.setPort(d.listenerPort);
 
     RETURN_IF_FAIL(listeningAddress, nullptr, "Could not determine IP address for this transport");
-    DEBUG("Creating TLS listener %s on %s...", d.toString().c_str(), listeningAddress.toString(true).c_str());
+    SFL_DBG("Creating TLS listener %s on %s...", d.toString().c_str(), listeningAddress.toString(true).c_str());
 #if 0
-    DEBUG(" ca_list_file : %s", settings->ca_list_file.ptr);
-    DEBUG(" cert_file    : %s", settings->cert_file.ptr);
-    DEBUG(" ciphers_num    : %d", settings->ciphers_num);
-    DEBUG(" verify server %d client %d client_cert %d", settings->verify_server, settings->verify_client, settings->require_client_cert);
-    DEBUG(" reuse_addr    : %d", settings->reuse_addr);
+    SFL_DBG(" ca_list_file : %s", settings->ca_list_file.ptr);
+    SFL_DBG(" cert_file    : %s", settings->cert_file.ptr);
+    SFL_DBG(" ciphers_num    : %d", settings->ciphers_num);
+    SFL_DBG(" verify server %d client %d client_cert %d", settings->verify_server, settings->verify_client, settings->require_client_cert);
+    SFL_DBG(" reuse_addr    : %d", settings->reuse_addr);
 #endif
 
     pjsip_tpfactory *listener = nullptr;
     const pj_status_t status = pjsip_tls_transport_start2(endpt_, settings, listeningAddress.pjPtr(), nullptr, 1, &listener);
     if (status != PJ_SUCCESS) {
-        ERROR("TLS listener did not start");
+        SFL_ERR("TLS listener did not start");
         sip_utils::sip_strerror(status);
         return nullptr;
     }
@@ -319,7 +319,7 @@ std::shared_ptr<SipTransport>
 SipTransportBroker::getTlsTransport(const std::shared_ptr<TlsListener>& l, const std::string& remoteSipUri)
 {
     if (!l) {
-        ERROR("Can't create TLS transport without listener.");
+        SFL_ERR("Can't create TLS transport without listener.");
         return nullptr;
     }
 
@@ -328,13 +328,13 @@ SipTransportBroker::getTlsTransport(const std::shared_ptr<TlsListener>& l, const
     size_t trns = remoteSipUri.find(";transport");
     const std::string remoteHost {remoteSipUri.substr(sips, trns-sips)};
     IpAddr remoteAddr = {remoteHost};
-    DEBUG("getTlsTransport host %s resolved to -> %s", remoteHost.c_str(), remoteAddr.toString(true).c_str());
+    SFL_DBG("getTlsTransport host %s resolved to -> %s", remoteHost.c_str(), remoteAddr.toString(true).c_str());
     if (!remoteAddr)
         return nullptr;
     if (remoteAddr.getPort() == 0)
         remoteAddr.setPort(pjsip_transport_get_default_port_for_type(l->get()->type));
 
-    DEBUG("Get new TLS transport to %s", remoteAddr.toString(true).c_str());
+    SFL_DBG("Get new TLS transport to %s", remoteAddr.toString(true).c_str());
     pjsip_tpselector sel {PJSIP_TPSELECTOR_LISTENER, {
         .listener = l->get()
     }};
@@ -348,7 +348,7 @@ SipTransportBroker::getTlsTransport(const std::shared_ptr<TlsListener>& l, const
             &transport);
 
     if (!transport || status != PJ_SUCCESS) {
-        ERROR("Could not get new TLS transport");
+        SFL_ERR("Could not get new TLS transport");
         sip_utils::sip_strerror(status);
         return nullptr;
     }
@@ -367,16 +367,18 @@ SipTransportBroker::getSTUNAddresses(const pj_str_t serverName, pj_uint16_t port
 {
     const size_t ip_num = socketDescriptors.size();
     pj_sockaddr_in ipv4[ip_num];
-    pj_status_t ret;
-    if ((ret = pjstun_get_mapped_addr(&cp_.factory, socketDescriptors.size(), &socketDescriptors[0],
-                    &serverName, port, &serverName, port, ipv4)) != PJ_SUCCESS) {
-        ERROR("STUN query to server \"%.*s\" failed", serverName.slen, serverName.ptr);
+    pj_status_t ret = pjstun_get_mapped_addr(&cp_.factory,
+		socketDescriptors.size(), &socketDescriptors[0],
+		&serverName, port, &serverName, port, ipv4);
+
+    if (ret != PJ_SUCCESS) {
+        SFL_ERR("STUN query to server \"%.*s\" failed", serverName.slen, serverName.ptr);
         switch (ret) {
             case PJLIB_UTIL_ESTUNNOTRESPOND:
-                ERROR("No response from STUN server(s)");
+                SFL_ERR("No response from STUN server(s)");
                 break;
             case PJLIB_UTIL_ESTUNSYMMETRIC:
-                ERROR("Different mapped addresses are returned by servers.");
+                SFL_ERR("Different mapped addresses are returned by servers.");
                 break;
             default:
                 break;
@@ -387,12 +389,12 @@ SipTransportBroker::getSTUNAddresses(const pj_str_t serverName, pj_uint16_t port
     std::vector<pj_sockaddr> result(ip_num);
     for(size_t i=0; i<ip_num; i++) {
         result[i].ipv4 = ipv4[i];
-        WARN("STUN PORTS: %ld", pj_sockaddr_get_port(&result[i]));
+        SFL_WARN("STUN PORTS: %ld", pj_sockaddr_get_port(&result[i]));
     }
     return result;
 }
 
-#define RETURN_IF_NULL(A, M, ...) if ((A) == NULL) { ERROR(M, ##__VA_ARGS__); return; }
+#define RETURN_IF_NULL(A, M, ...) if ((A) == NULL) { SFL_ERR(M, ##__VA_ARGS__); return; }
 
 void
 SipTransportBroker::findLocalAddressFromTransport(pjsip_transport *transport, pjsip_transport_type_e transportType, const std::string &host, std::string &addr, pj_uint16_t &port) const
@@ -416,7 +418,7 @@ SipTransportBroker::findLocalAddressFromTransport(pjsip_transport *transport, pj
     pjsip_tpselector tp_sel = getTransportSelector(transport);
     pjsip_tpmgr_fla2_param param = {transportType, &tp_sel, pjstring, PJ_FALSE, {nullptr, 0}, 0, nullptr};
     if (pjsip_tpmgr_find_local_addr2(tpmgr, &pool_, &param) != PJ_SUCCESS) {
-        WARN("Could not retrieve local address and port from transport, using %s :%d", addr.c_str(), port);
+        SFL_WARN("Could not retrieve local address and port from transport, using %s :%d", addr.c_str(), port);
         return;
     }
 
@@ -450,10 +452,10 @@ SipTransportBroker::findLocalAddressFromSTUN(pjsip_transport *transport,
 
     switch (stunStatus) {
         case PJLIB_UTIL_ESTUNNOTRESPOND:
-           ERROR("No response from STUN server %.*s", stunServerName->slen, stunServerName->ptr);
+           SFL_ERR("No response from STUN server %.*s", stunServerName->slen, stunServerName->ptr);
            return;
         case PJLIB_UTIL_ESTUNSYMMETRIC:
-           ERROR("Different mapped addresses are returned by servers.");
+           SFL_ERR("Different mapped addresses are returned by servers.");
            return;
         case PJ_SUCCESS:
             port = mapped_addr.getPort();
@@ -462,7 +464,7 @@ SipTransportBroker::findLocalAddressFromSTUN(pjsip_transport *transport,
            break;
     }
 
-    WARN("Using address %s provided by STUN server %.*s",
+    SFL_WARN("Using address %s provided by STUN server %.*s",
          IpAddr(mapped_addr).toString(true).c_str(), stunServerName->slen, stunServerName->ptr);
 }
 
diff --git a/daemon/src/sip/siptransport.h b/daemon/src/sip/siptransport.h
index e2a4dc5c310b3de682d626f9014aaf8fb51f1777..5dc5f64225b5017d5fb52f1f3e97e7d4c1bc2fab 100644
--- a/daemon/src/sip/siptransport.h
+++ b/daemon/src/sip/siptransport.h
@@ -89,7 +89,7 @@ struct TlsListener
     TlsListener() {}
     TlsListener(pjsip_tpfactory* f) : listener(f) {}
     virtual ~TlsListener() {
-        DEBUG("Destroying listener");
+        SFL_DBG("Destroying listener");
         listener->destroy(listener);
     }
     pjsip_tpfactory* get() {
diff --git a/daemon/src/sip/sipvoiplink.cpp b/daemon/src/sip/sipvoiplink.cpp
index 8c75b28e4a39f9a09daa14bf69f47e347d547345..57f322f13d67216a0a46628864d5ea5c1f660a78 100644
--- a/daemon/src/sip/sipvoiplink.cpp
+++ b/daemon/src/sip/sipvoiplink.cpp
@@ -193,7 +193,7 @@ try_respond_stateless(pjsip_endpoint *endpt, pjsip_rx_data *rdata, int st_code,
     if (!pjsip_rdata_get_tsx(rdata))
         return pjsip_endpt_respond_stateless(endpt, rdata, st_code, st_text, hdr_list, body);
     else
-        ERROR("Transaction has been created for this request, send response "
+        SFL_ERR("Transaction has been created for this request, send response "
               "statefully instead");
 
     return !PJ_SUCCESS;
@@ -203,14 +203,14 @@ static pj_bool_t
 transaction_request_cb(pjsip_rx_data *rdata)
 {
     if (!rdata or !rdata->msg_info.msg) {
-        ERROR("rx_data is NULL");
+        SFL_ERR("rx_data is NULL");
         return PJ_FALSE;
     }
 
     pjsip_method *method = &rdata->msg_info.msg->line.req.method;
 
     if (!method) {
-        ERROR("method is NULL");
+        SFL_ERR("method is NULL");
         return PJ_FALSE;
     }
 
@@ -218,7 +218,7 @@ transaction_request_cb(pjsip_rx_data *rdata)
         return PJ_FALSE;
 
     if (!rdata->msg_info.to or !rdata->msg_info.from or !rdata->msg_info.via) {
-        ERROR("Missing From, To or Via fields");
+        SFL_ERR("Missing From, To or Via fields");
         return PJ_FALSE;
     }
     const pjsip_sip_uri *sip_to_uri = (pjsip_sip_uri *) pjsip_uri_get_uri(rdata->msg_info.to->uri);
@@ -226,7 +226,7 @@ transaction_request_cb(pjsip_rx_data *rdata)
     const pjsip_host_port& sip_via = rdata->msg_info.via->sent_by;
 
     if (!sip_to_uri or !sip_from_uri or !sip_via.host.ptr) {
-        ERROR("NULL uri");
+        SFL_ERR("NULL uri");
         return PJ_FALSE;
     }
     std::string toUsername(sip_to_uri->user.ptr, sip_to_uri->user.slen);
@@ -237,7 +237,7 @@ transaction_request_cb(pjsip_rx_data *rdata)
 
     auto account(getSIPVoIPLink()->guessAccount(toUsername, viaHostname, remote_hostname));
     if (!account) {
-        ERROR("NULL account");
+        SFL_ERR("NULL account");
         return PJ_FALSE;
     }
 
@@ -309,17 +309,17 @@ transaction_request_cb(pjsip_rx_data *rdata)
     if (not remote_user.empty() and not remote_hostname.empty())
         peerNumber = remote_user + "@" + remote_hostname;
 
-    // DEBUG("transaction_request_cb viaHostname %s toUsername %s addrToUse %s addrSdp %s peerNumber: %s" ,
+    // SFL_DBG("transaction_request_cb viaHostname %s toUsername %s addrToUse %s addrSdp %s peerNumber: %s" ,
     // viaHostname.c_str(), toUsername.c_str(), addrToUse.toString().c_str(), addrSdp.toString().c_str(), peerNumber.c_str());
 
     auto transport = getSIPVoIPLink()->sipTransport->findTransport(rdata->tp_info.transport);
     if (!transport) {
         transport = account->getTransport();
         if (!transport) {
-            ERROR("No suitable transport to answer this call.");
+            SFL_ERR("No suitable transport to answer this call.");
             return PJ_FALSE;
         } else {
-            WARN("Using transport from account.");
+            SFL_WARN("Using transport from account.");
         }
     }
 
@@ -335,7 +335,7 @@ transaction_request_cb(pjsip_rx_data *rdata)
     try {
         call->getAudioRtp().initSession();
     } catch (const ost::Socket::Error &err) {
-        ERROR("AudioRtp socket error");
+        SFL_ERR("AudioRtp socket error");
         return PJ_FALSE;
     }
 
@@ -365,7 +365,7 @@ transaction_request_cb(pjsip_rx_data *rdata)
                     call->getAudioRtp().setRemoteCryptoInfo(sdesnego);
                     call->getAudioRtp().initLocalCryptoInfo();
                 } catch (const AudioRtpFactoryException &e) {
-                    ERROR("%s", e.what());
+                    SFL_ERR("%s", e.what());
                     return PJ_FALSE;
                 }
             }
@@ -379,7 +379,7 @@ transaction_request_cb(pjsip_rx_data *rdata)
     sfl::AudioCodec* ac = Manager::instance().audioCodecFactory.instantiateCodec(PAYLOAD_CODEC_ULAW);
 
     if (!ac) {
-        ERROR("Could not instantiate codec");
+        SFL_ERR("Could not instantiate codec");
         return PJ_FALSE;
     }
 
@@ -397,7 +397,7 @@ transaction_request_cb(pjsip_rx_data *rdata)
 
     pjsip_tpselector tp_sel  = SipTransportBroker::getTransportSelector(transport->get());
     if (!dialog or pjsip_dlg_set_transport(dialog, &tp_sel) != PJ_SUCCESS) {
-        ERROR("Could not set transport for dialog");
+        SFL_ERR("Could not set transport for dialog");
         return PJ_FALSE;
     }
 
@@ -405,7 +405,7 @@ transaction_request_cb(pjsip_rx_data *rdata)
     pjsip_inv_create_uas(dialog, rdata, call->getLocalSDP().getLocalSdpSession(), 0, &inv);
 
     if (!inv) {
-        ERROR("Call invite is not initialized");
+        SFL_ERR("Call invite is not initialized");
         return PJ_FALSE;
     }
 
@@ -417,7 +417,7 @@ transaction_request_cb(pjsip_rx_data *rdata)
     pjsip_tx_data *response;
 
     if (pjsip_replaces_verify_request(rdata, &replaced_dlg, PJ_FALSE, &response) != PJ_SUCCESS) {
-        ERROR("Something wrong with Replaces request.");
+        SFL_ERR("Something wrong with Replaces request.");
         call.reset();
 
         // Something wrong with the Replaces header.
@@ -454,12 +454,12 @@ transaction_request_cb(pjsip_rx_data *rdata)
         }
     } else { // Proceed with normal call flow
         if (pjsip_inv_initial_answer(call->inv.get(), rdata, PJSIP_SC_TRYING, NULL, NULL, &tdata) != PJ_SUCCESS) {
-            ERROR("Could not answer invite");
+            SFL_ERR("Could not answer invite");
             return PJ_FALSE;
         }
 
         if (pjsip_inv_send_msg(call->inv.get(), tdata) != PJ_SUCCESS) {
-            ERROR("Could not send msg for invite");
+            SFL_ERR("Could not send msg for invite");
             call->inv.reset();
             return PJ_FALSE;
         }
@@ -467,7 +467,7 @@ transaction_request_cb(pjsip_rx_data *rdata)
         call->setConnectionState(Call::TRYING);
 
         if (pjsip_inv_answer(call->inv.get(), PJSIP_SC_RINGING, NULL, NULL, &tdata) != PJ_SUCCESS) {
-            ERROR("Could not answer invite");
+            SFL_ERR("Could not answer invite");
             return PJ_FALSE;
         }
 
@@ -476,7 +476,7 @@ transaction_request_cb(pjsip_rx_data *rdata)
         sip_utils::addContactHeader(&contactStr, tdata);
 
         if (pjsip_inv_send_msg(call->inv.get(), tdata) != PJ_SUCCESS) {
-            ERROR("Could not send msg for invite");
+            SFL_ERR("Could not send msg for invite");
             call->inv.reset();
             return PJ_FALSE;
         }
@@ -508,7 +508,7 @@ pj_pool_t* SIPVoIPLink::getPool() const
 
 SIPVoIPLink::SIPVoIPLink()
 {
-    DEBUG("creating SIPVoIPLink instance");
+    SFL_DBG("creating SIPVoIPLink instance");
 
 #define TRY(ret) do { \
     if (ret != PJ_SUCCESS) \
@@ -575,7 +575,7 @@ SIPVoIPLink::SIPVoIPLink()
     TRY(pjsip_inv_usage_init(endpt_, &inv_cb));
 
     static const pj_str_t allowed[] = {
-        CONST_PJ_STR("INFO"),
+        CONST_PJ_STR("SFL_INFO"),
         CONST_PJ_STR("OPTIONS"),
         CONST_PJ_STR("MESSAGE"),
         CONST_PJ_STR("PUBLISH"),
@@ -589,7 +589,7 @@ SIPVoIPLink::SIPVoIPLink()
     static const pj_str_t accepted = CONST_PJ_STR("application/sdp");
     pjsip_endpt_add_capability(endpt_, &mod_ua_, PJSIP_H_ACCEPT, nullptr, 1, &accepted);
 
-    DEBUG("pjsip version %s for %s initialized", pj_get_version(), PJ_OS_NAME);
+    SFL_DBG("pjsip version %s for %s initialized", pj_get_version(), PJ_OS_NAME);
 
     TRY(pjsip_replaces_init_module(endpt_));
 #undef TRY
@@ -602,7 +602,7 @@ SIPVoIPLink::SIPVoIPLink()
 
 SIPVoIPLink::~SIPVoIPLink()
 {
-    DEBUG("destroying SIPVoIPLink instance");
+    SFL_DBG("destroying SIPVoIPLink instance");
 
     const int MAX_TIMEOUT_ON_LEAVING = 5;
 
@@ -615,7 +615,7 @@ SIPVoIPLink::~SIPVoIPLink()
     pjsip_endpt_handle_events(endpt_, &tv);
 
     if (!Manager::instance().callFactory.empty<SIPCall>())
-        ERROR("%d SIP calls remains!",
+        SFL_ERR("%d SIP calls remains!",
               Manager::instance().callFactory.callCount<SIPCall>());
 
     // destroy SIP transport before endpoint
@@ -634,7 +634,7 @@ SIPVoIPLink::guessAccount(const std::string& userName,
                            const std::string& server,
                            const std::string& fromUri) const
 {
-    DEBUG("username = %s, server = %s, from = %s", userName.c_str(), server.c_str(), fromUri.c_str());
+    SFL_DBG("username = %s, server = %s, from = %s", userName.c_str(), server.c_str(), fromUri.c_str());
     // Try to find the account id from username and server name by full match
 
     auto result = std::static_pointer_cast<SIPAccountBase>(Manager::instance().getIP2IPAccount()); // default result
@@ -706,7 +706,7 @@ SIPVoIPLink::handleEvents()
         static __thread pj_thread_desc desc;
         static __thread pj_thread_t *this_thread;
 #endif
-        DEBUG("Registering thread");
+        SFL_DBG("Registering thread");
         pj_thread_register(NULL, desc, &this_thread);
     }
 
@@ -723,25 +723,25 @@ SIPVoIPLink::handleEvents()
 
 void SIPVoIPLink::registerKeepAliveTimer(pj_timer_entry &timer, pj_time_val &delay)
 {
-    DEBUG("Register new keep alive timer %d with delay %d", timer.id, delay.sec);
+    SFL_DBG("Register new keep alive timer %d with delay %d", timer.id, delay.sec);
 
     if (timer.id == -1)
-        WARN("Timer already scheduled");
+        SFL_WARN("Timer already scheduled");
 
     switch (pjsip_endpt_schedule_timer(endpt_, &timer, &delay)) {
         case PJ_SUCCESS:
             break;
 
         default:
-            ERROR("Could not schedule new timer in pjsip endpoint");
+            SFL_ERR("Could not schedule new timer in pjsip endpoint");
 
             /* fallthrough */
         case PJ_EINVAL:
-            ERROR("Invalid timer or delay entry");
+            SFL_ERR("Invalid timer or delay entry");
             break;
 
         case PJ_EINVALIDOP:
-            ERROR("Invalid timer entry, maybe already scheduled");
+            SFL_ERR("Invalid timer entry, maybe already scheduled");
             break;
     }
 }
@@ -794,7 +794,7 @@ SIPVoIPLink::requestKeyframe(const std::string &callID)
         "<picture_fast_update/>"
         "</to_encoder></vc_primitive></media_control>";
 
-    DEBUG("Sending video keyframe request via SIP INFO");
+    SFL_DBG("Sending video keyframe request via SIP SFL_INFO");
     call->sendSIPInfo(BODY, "media_control+xml");
 }
 #endif
@@ -864,7 +864,7 @@ invite_session_state_changed_cb(pjsip_inv_session *inv, pjsip_event *ev)
             case PJSIP_SC_REQUEST_PENDING:
             case PJSIP_SC_ADDRESS_INCOMPLETE:
             default:
-                WARN("PJSIP_INV_STATE_DISCONNECTED: %d %d", inv->cause, ev->type);
+                SFL_WARN("PJSIP_INV_STATE_DISCONNECTED: %d %d", inv->cause, ev->type);
                 call->onServerFailure();
                 break;
         }
@@ -927,7 +927,7 @@ sdp_media_update_cb(pjsip_inv_session *inv, pj_status_t status)
 
     auto call = static_cast<SIPCall*>(inv->mod_data[mod_ua_.id]);
     if (!call) {
-        DEBUG("Call declined by peer, SDP negotiation stopped");
+        SFL_DBG("Call declined by peer, SDP negotiation stopped");
         return;
     }
 
@@ -936,7 +936,7 @@ sdp_media_update_cb(pjsip_inv_session *inv, pj_status_t status)
                            inv->state != PJSIP_INV_STATE_CONFIRMED ?
                            PJSIP_SC_UNSUPPORTED_MEDIA_TYPE : 0;
 
-        WARN("Could not negotiate offer");
+        SFL_WARN("Could not negotiate offer");
         const std::string callID(call->getCallId());
         call->hangup(reason);
         Manager::instance().callFailure(callID);
@@ -944,7 +944,7 @@ sdp_media_update_cb(pjsip_inv_session *inv, pj_status_t status)
     }
 
     if (!inv->neg) {
-        WARN("No negotiator for this session");
+        SFL_WARN("No negotiator for this session");
         return;
     }
 
@@ -955,12 +955,12 @@ sdp_media_update_cb(pjsip_inv_session *inv, pj_status_t status)
     const pjmedia_sdp_session *remoteSDP = 0;
 
     if (pjmedia_sdp_neg_get_active_remote(inv->neg, &remoteSDP) != PJ_SUCCESS) {
-        ERROR("Active remote not present");
+        SFL_ERR("Active remote not present");
         return;
     }
 
     if (pjmedia_sdp_validate(remoteSDP) != PJ_SUCCESS) {
-        ERROR("Invalid remote SDP session");
+        SFL_ERR("Invalid remote SDP session");
         return;
     }
 
@@ -968,7 +968,7 @@ sdp_media_update_cb(pjsip_inv_session *inv, pj_status_t status)
     pjmedia_sdp_neg_get_active_local(inv->neg, &local_sdp);
 
     if (pjmedia_sdp_validate(local_sdp) != PJ_SUCCESS) {
-        ERROR("Invalid local SDP session");
+        SFL_ERR("Invalid local SDP session");
         return;
     }
 
@@ -977,20 +977,20 @@ sdp_media_update_cb(pjsip_inv_session *inv, pj_status_t status)
     memset(buffer, 0, sizeof buffer);
 
     if (pjmedia_sdp_print(remoteSDP, buffer, sizeof buffer) == -1) {
-        ERROR("SDP was too big for buffer");
+        SFL_ERR("SDP was too big for buffer");
         return;
     }
 
-    DEBUG("Remote active SDP Session:\n%s", buffer);
+    SFL_DBG("Remote active SDP Session:\n%s", buffer);
 
     memset(buffer, 0, sizeof buffer);
 
     if (pjmedia_sdp_print(local_sdp, buffer, sizeof buffer) == -1) {
-        ERROR("SDP was too big for buffer");
+        SFL_ERR("SDP was too big for buffer");
         return;
     }
 
-    DEBUG("Local active SDP Session:\n%s", buffer);
+    SFL_DBG("Local active SDP Session:\n%s", buffer);
 
     // Set active SDP sessions
     sdpSession.setActiveLocalSdpSession(local_sdp);
@@ -1002,7 +1002,7 @@ sdp_media_update_cb(pjsip_inv_session *inv, pj_status_t status)
     try {
         call->getAudioRtp().updateDestinationIpAddress();
     } catch (const AudioRtpFactoryException &e) {
-        ERROR("%s", e.what());
+        SFL_ERR("%s", e.what());
     }
 
     call->getAudioRtp().setDtmfPayloadType(sdpSession.getTelephoneEventType());
@@ -1037,20 +1037,20 @@ sdp_media_update_cb(pjsip_inv_session *inv, pj_status_t status)
                 call->getAudioRtp().setRemoteCryptoInfo(sdesnego);
                 Manager::instance().getClient()->getCallManager()->secureSdesOn(call->getCallId());
             } catch (const AudioRtpFactoryException &e) {
-                ERROR("%s", e.what());
+                SFL_ERR("%s", e.what());
                 Manager::instance().getClient()->getCallManager()->secureSdesOff(call->getCallId());
             }
         } else {
-            ERROR("SDES negotiation failure");
+            SFL_ERR("SDES negotiation failure");
             Manager::instance().getClient()->getCallManager()->secureSdesOff(call->getCallId());
         }
     } else {
-        DEBUG("No crypto offer available");
+        SFL_DBG("No crypto offer available");
     }
 
     // We did not find any crypto context for this media, RTP fallback
     if (!nego_success && call->getAudioRtp().isSdesEnabled()) {
-        ERROR("Negotiation failed but SRTP is enabled, fallback on RTP");
+        SFL_ERR("Negotiation failed but SRTP is enabled, fallback on RTP");
         call->getAudioRtp().stop();
         call->getAudioRtp().setSrtpEnabled(false);
 
@@ -1068,7 +1068,7 @@ sdp_media_update_cb(pjsip_inv_session *inv, pj_status_t status)
     std::vector<sfl::AudioCodec*> sessionMedia(sdpSession.getSessionAudioMedia());
 
     if (sessionMedia.empty()) {
-        WARN("Session media is empty");
+        SFL_WARN("Session media is empty");
         return;
     }
 
@@ -1086,7 +1086,7 @@ sdp_media_update_cb(pjsip_inv_session *inv, pj_status_t status)
             sfl::AudioCodec *ac = Manager::instance().audioCodecFactory.instantiateCodec(pl);
 
             if (!ac) {
-                ERROR("Could not instantiate codec %d", pl);
+                SFL_ERR("Could not instantiate codec %d", pl);
             } else {
                 audioCodecs.push_back(ac);
             }
@@ -1095,9 +1095,9 @@ sdp_media_update_cb(pjsip_inv_session *inv, pj_status_t status)
         if (not audioCodecs.empty())
             call->getAudioRtp().updateSessionMedia(audioCodecs);
     } catch (const SdpException &e) {
-        ERROR("%s", e.what());
+        SFL_ERR("%s", e.what());
     } catch (const std::exception &rtpException) {
-        ERROR("%s", rtpException.what());
+        SFL_ERR("%s", rtpException.what());
     }
 }
 
@@ -1109,7 +1109,7 @@ static bool
 handle_media_control(pjsip_inv_session * inv, pjsip_transaction *tsx, pjsip_event *event)
 {
     /*
-     * Incoming INFO request for media control.
+     * Incoming SFL_INFO request for media control.
      */
     const pj_str_t STR_APPLICATION = CONST_PJ_STR("application");
     const pj_str_t STR_MEDIA_CONTROL_XML = CONST_PJ_STR("media_control+xml");
@@ -1120,13 +1120,13 @@ handle_media_control(pjsip_inv_session * inv, pjsip_transaction *tsx, pjsip_even
             pj_stricmp(&body->content_type.subtype, &STR_MEDIA_CONTROL_XML) == 0) {
         pj_str_t control_st;
 
-        /* Apply and answer the INFO request */
+        /* Apply and answer the SFL_INFO request */
         pj_strset(&control_st, (char *) body->data, body->len);
         const pj_str_t PICT_FAST_UPDATE = CONST_PJ_STR("picture_fast_update");
 
         if (pj_strstr(&control_st, &PICT_FAST_UPDATE)) {
 #ifdef SFL_VIDEO
-            DEBUG("handling picture fast update request");
+            SFL_DBG("handling picture fast update request");
             auto call = static_cast<SIPCall*>(inv->mod_data[mod_ua_.id]);
             if (call)
                 call->getVideoRtp().forceKeyFrame();
@@ -1185,10 +1185,10 @@ transaction_state_changed_cb(pjsip_inv_session * inv, pjsip_transaction *tsx,
 
         if (r_data->msg_info.msg->line.req.method.id == PJSIP_OTHER_METHOD) {
             std::string request(pjsip_rx_data_get_info(r_data));
-            DEBUG("%s", request.c_str());
+            SFL_DBG("%s", request.c_str());
 
             if (request.find("NOTIFY") == std::string::npos and
-                    request.find("INFO") != std::string::npos) {
+                    request.find("SFL_INFO") != std::string::npos) {
                 sendOK(inv->dlg, r_data, tsx);
                 return;
             }
@@ -1197,17 +1197,17 @@ transaction_state_changed_cb(pjsip_inv_session * inv, pjsip_transaction *tsx,
 
             if (body and body->len > 0) {
                 const std::string msg(static_cast<char *>(body->data), body->len);
-                DEBUG("%s", msg.c_str());
+                SFL_DBG("%s", msg.c_str());
 
                 if (msg.find("Not found") != std::string::npos) {
-                    ERROR("Received 404 Not found");
+                    SFL_ERR("Received 404 Not found");
                     sendOK(inv->dlg, r_data, tsx);
                     return;
                 } else if (msg.find("Ringing") != std::string::npos and call) {
                     if (call)
                         makeCallRing(*call);
                     else
-                        WARN("Ringing state on non existing call");
+                        SFL_WARN("Ringing state on non existing call");
                     sendOK(inv->dlg, r_data, tsx);
                     return;
                 } else if (msg.find("Ok") != std::string::npos) {
@@ -1265,7 +1265,7 @@ transaction_state_changed_cb(pjsip_inv_session * inv, pjsip_transaction *tsx,
         sendOK(inv->dlg, r_data, tsx);
 
     } catch (const sfl::InstantMessageException &except) {
-        ERROR("%s", except.what());
+        SFL_ERR("%s", except.what());
     }
 #endif
 }
@@ -1293,7 +1293,7 @@ onCallTransfered(pjsip_inv_session *inv, pjsip_rx_data *rdata)
                                             currentCall->getAccountId());
         Manager::instance().hangupCall(currentCall->getCallId());
     } catch (const VoipLinkException &e) {
-        ERROR("%s", e.what());
+        SFL_ERR("%s", e.what());
     }
 }
 
diff --git a/daemon/src/sip/tlsvalidation.c b/daemon/src/sip/tlsvalidation.c
index 7cf8523b50898a2b61391b32eebb008ceb34c458..3d93ac5b7459f27761d550de55a6047bbc41cbeb 100644
--- a/daemon/src/sip/tlsvalidation.c
+++ b/daemon/src/sip/tlsvalidation.c
@@ -71,24 +71,24 @@ static unsigned char *crypto_file_read(const char *path, size_t *out_len)
 
     fd = open(path, O_RDONLY);
     if (fd < 0) {
-        ERROR("Failed to open file '%s'.", path);
+        SFL_ERR("Failed to open file '%s'.", path);
         return NULL;
     }
 
     if (fstat(fd, &st) < 0) {
-        ERROR("Failed to stat file '%s'.", path);
+        SFL_ERR("Failed to stat file '%s'.", path);
         goto out;
     }
 
     if (st.st_size <= 0 || st.st_size > INT_MAX) {
-        ERROR("Invalid file '%s' length %ld.", path, st.st_size);
+        SFL_ERR("Invalid file '%s' length %ld.", path, st.st_size);
         goto out;
     }
 
     file_size = st.st_size;
     data = (unsigned char *)malloc(file_size);
     if (!data) {
-        ERROR("Not enough memory to read file '%s'.", path);
+        SFL_ERR("Not enough memory to read file '%s'.", path);
         goto out;
     }
 
@@ -98,7 +98,7 @@ static unsigned char *crypto_file_read(const char *path, size_t *out_len)
             free(data);
             data = NULL;
             *out_len = 0;
-            ERROR("Failed to read file '%s'.", path);
+            SFL_ERR("Failed to read file '%s'.", path);
             goto out;
         }
         *out_len += bytes_read;
@@ -119,21 +119,21 @@ static int crypto_cert_check_date(gnutls_x509_crt_t cert)
 
     activationTime = gnutls_x509_crt_get_activation_time(cert);
     if (activationTime == -1) {
-        ERROR("Could not retrieve activation time.");
+        SFL_ERR("Could not retrieve activation time.");
         return -1;
     }
     if (now < activationTime) {
-        ERROR("Certificate not yet activated.");
+        SFL_ERR("Certificate not yet activated.");
         return -1;
     }
 
     expirationTime = gnutls_x509_crt_get_expiration_time(cert);
     if (expirationTime == -1) {
-        ERROR("Could not errrieve expiration time.");
+        SFL_ERR("Could not errrieve expiration time.");
         return -2;
     }
     if (now > expirationTime) {
-        ERROR("Certificate expired.");
+        SFL_ERR("Certificate expired.");
         return -2;
     }
 
@@ -157,7 +157,7 @@ static unsigned char *crypto_cert_read(const char *path, size_t *out_len)
 
     dt.size = (unsigned int) fsize;
     if (gnutls_x509_crt_init(&cert) != GNUTLS_E_SUCCESS) {
-        ERROR("Not enough memory for certificate.");
+        SFL_ERR("Not enough memory for certificate.");
         goto out;
     }
 
@@ -165,7 +165,7 @@ static unsigned char *crypto_cert_read(const char *path, size_t *out_len)
     if (err != GNUTLS_E_SUCCESS)
         err = gnutls_x509_crt_import(cert, &dt, GNUTLS_X509_FMT_DER);
     if (err != GNUTLS_E_SUCCESS) {
-        ERROR("Could not import certificate %s - %s", path, gnutls_strerror(err));
+        SFL_ERR("Could not import certificate %s - %s", path, gnutls_strerror(err));
         goto out;
     }
 
@@ -183,7 +183,7 @@ static unsigned char *crypto_cert_read(const char *path, size_t *out_len)
         free(data);
         data = NULL;
         *out_len = 0;
-        ERROR("Certificate %s could not be exported - %s.\n",
+        SFL_ERR("Certificate %s could not be exported - %s.\n",
               path, gnutls_strerror(err));
     }
 
@@ -210,22 +210,22 @@ static int crypto_cert_load_trusted(gnutls_certificate_credentials_t cred)
 
     trust_store = opendir("/etc/ssl/certs/");
     if (!trust_store) {
-        ERROR("Failed to open system trusted store.");
+        SFL_ERR("Failed to open system trusted store.");
         goto out;
     }
     while ((trust_ca = readdir(trust_store)) != NULL) {
         /* Prepare the string and check it is a regular file. */
         err = snprintf(ca_file, sizeof(ca_file), "/etc/ssl/certs/%s", trust_ca->d_name);
         if (err < 0) {
-            ERROR("snprintf() error");
+            SFL_ERR("snprintf() error");
             goto out;
         } else if (err >= sizeof(ca_file)) {
-            ERROR("File name too long '%s'.", trust_ca->d_name);
+            SFL_ERR("File name too long '%s'.", trust_ca->d_name);
             goto out;
         }
         err = stat(ca_file, &statbuf);
         if (err < 0) {
-            ERROR("Failed to stat file '%s'.", ca_file);
+            SFL_ERR("Failed to stat file '%s'.", ca_file);
             goto out;
         }
         if (!S_ISREG(statbuf.st_mode))
@@ -234,9 +234,9 @@ static int crypto_cert_load_trusted(gnutls_certificate_credentials_t cred)
         /* Load the root CA. */
         err = gnutls_certificate_set_x509_trust_file(cred, ca_file, GNUTLS_X509_FMT_PEM);
         if (err == 0) {
-            WARN("No trusted certificates found - %s", gnutls_strerror(err));
+            SFL_WARN("No trusted certificates found - %s", gnutls_strerror(err));
         } else if (err < 0) {
-            ERROR("Could not load trusted certificates - %s", gnutls_strerror(err));
+            SFL_ERR("Could not load trusted certificates - %s", gnutls_strerror(err));
             goto out;
         }
     }
@@ -265,14 +265,14 @@ static int crypto_cert_print_issuer(gnutls_x509_crt_t cert,
     name_size = sizeof(name);
     gnutls_x509_crt_get_dn(cert, name, &name_size);
 
-    DEBUG("Subject: %s", name);
-    DEBUG("Issuer: %s", issuer_name);
+    SFL_DBG("Subject: %s", name);
+    SFL_DBG("Issuer: %s", issuer_name);
 
     if (issuer != NULL) {
         issuer_name_size = sizeof(issuer_name);
         gnutls_x509_crt_get_dn(issuer, issuer_name, &issuer_name_size);
 
-        DEBUG("Verified against: %s", issuer_name);
+        SFL_DBG("Verified against: %s", issuer_name);
     }
 
     return 0;
@@ -292,14 +292,14 @@ int containsPrivateKey(const char *pemPath)
 
     err = gnutls_global_init();
     if (err != GNUTLS_E_SUCCESS) {
-        ERROR("Could not init GnuTLS - %s", gnutls_strerror(err));
+        SFL_ERR("Could not init GnuTLS - %s", gnutls_strerror(err));
         free(dt.data);
         return res;
     }
 
     err = gnutls_x509_privkey_init(&key);
     if (err != GNUTLS_E_SUCCESS) {
-        ERROR("Could not init key - %s", gnutls_strerror(err));
+        SFL_ERR("Could not init key - %s", gnutls_strerror(err));
         free(dt.data);
         gnutls_global_deinit();
         return res;
@@ -309,12 +309,12 @@ int containsPrivateKey(const char *pemPath)
     if (err != GNUTLS_E_SUCCESS)
         err = gnutls_x509_privkey_import(key, &dt, GNUTLS_X509_FMT_DER);
     if (err != GNUTLS_E_SUCCESS) {
-        ERROR("Could not read key - %s", gnutls_strerror(err));
+        SFL_ERR("Could not read key - %s", gnutls_strerror(err));
         goto out;
     }
 
     res = 0;
-    DEBUG("Key from %s seems valid.", pemPath);
+    SFL_DBG("Key from %s seems valid.", pemPath);
 out:
     free(dt.data);
     gnutls_x509_privkey_deinit(key);
@@ -334,7 +334,7 @@ int certificateIsValid(const char *caPath, const char *certPath)
 
     err = gnutls_global_init();
     if (err != GNUTLS_E_SUCCESS) {
-        ERROR("Could not init GnuTLS - %s", gnutls_strerror(err));
+        SFL_ERR("Could not init GnuTLS - %s", gnutls_strerror(err));
         goto out;
     }
 
@@ -345,7 +345,7 @@ int certificateIsValid(const char *caPath, const char *certPath)
 
     err = gnutls_x509_crt_init(&cert);
     if (err != GNUTLS_E_SUCCESS) {
-        ERROR("Could not init certificate - %s", gnutls_strerror(err));
+        SFL_ERR("Could not init certificate - %s", gnutls_strerror(err));
         goto out;
     }
 
@@ -353,7 +353,7 @@ int certificateIsValid(const char *caPath, const char *certPath)
     if (err != GNUTLS_E_SUCCESS)
         err = gnutls_x509_crt_import(cert, &cert_dt, GNUTLS_X509_FMT_DER);
     if (err != GNUTLS_E_SUCCESS) {
-        ERROR("Could not read certificate - %s", gnutls_strerror(err));
+        SFL_ERR("Could not read certificate - %s", gnutls_strerror(err));
         goto out;
     }
     free(cert_dt.data);
@@ -362,7 +362,7 @@ int certificateIsValid(const char *caPath, const char *certPath)
     /* check if cert is self signed */
     self_signed = gnutls_x509_crt_check_issuer(cert, cert);
     if (!self_signed && !caPath) {
-        ERROR("Certificate is not self-signed, and CA is not provided.");
+        SFL_ERR("Certificate is not self-signed, and CA is not provided.");
         goto out;
     }
     if (caPath) {
@@ -373,7 +373,7 @@ int certificateIsValid(const char *caPath, const char *certPath)
 
         err = gnutls_x509_crt_init(&ca);
         if (err != GNUTLS_E_SUCCESS) {
-            ERROR("Could not init CA - %s", gnutls_strerror(err));
+            SFL_ERR("Could not init CA - %s", gnutls_strerror(err));
             goto out;
         }
 
@@ -381,7 +381,7 @@ int certificateIsValid(const char *caPath, const char *certPath)
         if (err != GNUTLS_E_SUCCESS)
             err = gnutls_x509_crt_import(ca, &ca_dt, GNUTLS_X509_FMT_DER);
         if (err != GNUTLS_E_SUCCESS) {
-            ERROR("Could not read CA - %s", gnutls_strerror(err));
+            SFL_ERR("Could not read CA - %s", gnutls_strerror(err));
             goto out;
         }
         free(ca_dt.data);
@@ -390,33 +390,33 @@ int certificateIsValid(const char *caPath, const char *certPath)
         /* Check if the CA is the issuer of certificate. */
         self_signed = gnutls_x509_crt_check_issuer(cert, ca);
         if (!self_signed) {
-            ERROR("Certificate is not issued by the provided CA.");
+            SFL_ERR("Certificate is not issued by the provided CA.");
             goto out;
         }
 
         /* Verify the certificate with its issuer. */
         err = gnutls_x509_crt_verify(cert, &ca, 1, 0, &output);
         if (err < 0) {
-            ERROR("Could not verify cert: %s", gnutls_strerror(err));
+            SFL_ERR("Could not verify cert: %s", gnutls_strerror(err));
             goto out;
         }
         if (output & GNUTLS_CERT_INVALID) {
-            ERROR("Verification failed.");
+            SFL_ERR("Verification failed.");
             if (output & GNUTLS_CERT_SIGNER_NOT_FOUND)
-                ERROR("The certificate hasn't got a known issuer.");
+                SFL_ERR("The certificate hasn't got a known issuer.");
             if (output & GNUTLS_CERT_SIGNER_NOT_CA)
-                ERROR("The certificate issuer is not a CA.");
+                SFL_ERR("The certificate issuer is not a CA.");
             if (output & GNUTLS_CERT_REVOKED)
-                ERROR("The certificate has been revoked.");
+                SFL_ERR("The certificate has been revoked.");
             if (output & GNUTLS_CERT_EXPIRED)
-                ERROR("The certificate has expired.");
+                SFL_ERR("The certificate has expired.");
             if (output & GNUTLS_CERT_NOT_ACTIVATED)
-                ERROR("The certificate is not yet activated.");
+                SFL_ERR("The certificate is not yet activated.");
             goto out;
         }
     }
 
-    DEBUG("Certificate from %s seems valid.", certPath);
+    SFL_DBG("Certificate from %s seems valid.", certPath);
     crypto_cert_print_issuer(cert, ca);
     res = 0;
 out:
@@ -454,14 +454,14 @@ int verifyHostnameCertificate(const char *host, const uint16_t port)
     struct timeval tv;
 
     if (!host || !port) {
-        ERROR("Wrong parameters used - host %s, port %d.", host, port);
+        SFL_ERR("Wrong parameters used - host %s, port %d.", host, port);
         return res;
     }
 
     /* Create the socket. */
     sockfd = socket (PF_INET, SOCK_STREAM, 0);
     if (sockfd < 0) {
-        ERROR("Could not create socket.");
+        SFL_ERR("Could not create socket.");
         return res;
     }
     /* Set non-blocking so we can dected timeouts. */
@@ -478,7 +478,7 @@ int verifyHostnameCertificate(const char *host, const uint16_t port)
     name.sin_port = htons(port);
     hostinfo = gethostbyname(host);
     if (hostinfo == NULL) {
-        ERROR("Unknown host %s.", host);
+        SFL_ERR("Unknown host %s.", host);
         goto out;
     }
     name.sin_addr = *(struct in_addr *)hostinfo->h_addr;
@@ -494,7 +494,7 @@ int verifyHostnameCertificate(const char *host, const uint16_t port)
                 tv.tv_usec = 0;
                 err = select(sockfd + 1, NULL, &fdset, NULL, &tv);
                 if (err < 0 && errno != EINTR) {
-                    ERROR("Could not connect to hostname %s at port %d",
+                    SFL_ERR("Could not connect to hostname %s at port %d",
                           host, port);
                     goto out;
                 } else if (err > 0) {
@@ -504,17 +504,17 @@ int verifyHostnameCertificate(const char *host, const uint16_t port)
                     getsockopt(sockfd, SOL_SOCKET, SO_ERROR, &so_error, &len);
 
                     if (so_error) {
-                        ERROR("Connection delayed.");
+                        SFL_ERR("Connection delayed.");
                         goto out;
                     }
                     break;  // exit do-while loop
                 } else {
-                    ERROR("Connection timeout.");
+                    SFL_ERR("Connection timeout.");
                     goto out;
                 }
             } while(1);
         } else {
-            ERROR("Could not connect to hostname %s at port %d", host, port);
+            SFL_ERR("Could not connect to hostname %s at port %d", host, port);
             goto out;
         }
     }
@@ -529,45 +529,45 @@ int verifyHostnameCertificate(const char *host, const uint16_t port)
     /* Disable Nagle algorithm that slows down the SSL handshake. */
     err = setsockopt(sockfd, IPPROTO_TCP, TCP_NODELAY, &one, sizeof(one));
     if (err < 0) {
-        ERROR("Could not set TCP_NODELAY.");
+        SFL_ERR("Could not set TCP_NODELAY.");
         goto out;
     }
 
     err = gnutls_global_init();
     if (err != GNUTLS_E_SUCCESS) {
-        ERROR("Could not init GnuTLS - %s", gnutls_strerror(err));
+        SFL_ERR("Could not init GnuTLS - %s", gnutls_strerror(err));
         goto out;
     }
     /* Load the trusted CA certificates. */
     err = gnutls_certificate_allocate_credentials(&cred);
     if (err != GNUTLS_E_SUCCESS) {
-        ERROR("Could not allocate credentials - %s", gnutls_strerror(err));
+        SFL_ERR("Could not allocate credentials - %s", gnutls_strerror(err));
         goto out;
     }
     err = crypto_cert_load_trusted(cred);
     if (err != GNUTLS_E_SUCCESS) {
-        ERROR("Could not load credentials.");
+        SFL_ERR("Could not load credentials.");
         goto out;
     }
 
     /* Create the session object. */
     err = gnutls_init(&session, GNUTLS_CLIENT);
     if (err != GNUTLS_E_SUCCESS) {
-        ERROR("Could not init session -%s\n", gnutls_strerror(err));
+        SFL_ERR("Could not init session -%s\n", gnutls_strerror(err));
         goto out;
     }
 
     /* Configure the cipher preferences. The default set should be good enough. */
     err = gnutls_priority_set_direct(session, "NORMAL", &errptr);
     if (err != GNUTLS_E_SUCCESS) {
-        ERROR("Could not set up ciphers - %s (%s)", gnutls_strerror(err), errptr);
+        SFL_ERR("Could not set up ciphers - %s (%s)", gnutls_strerror(err), errptr);
         goto out;
     }
 
     /* Install the trusted certificates. */
     err = gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, cred);
     if (err != GNUTLS_E_SUCCESS) {
-        ERROR("Could not set up credentials - %s", gnutls_strerror(err));
+        SFL_ERR("Could not set up credentials - %s", gnutls_strerror(err));
         goto out;
     }
 
@@ -575,28 +575,28 @@ int verifyHostnameCertificate(const char *host, const uint16_t port)
     gnutls_transport_set_ptr(session, (gnutls_transport_ptr_t) (uintptr_t) sockfd);
     err = gnutls_server_name_set(session, GNUTLS_NAME_DNS, host, strlen(host));
     if (err != GNUTLS_E_SUCCESS) {
-        ERROR("Could not set server name - %s", gnutls_strerror(err));
+        SFL_ERR("Could not set server name - %s", gnutls_strerror(err));
         goto out;
     }
 
     /* Establish the connection. */
     err = gnutls_handshake(session);
     if (err != GNUTLS_E_SUCCESS) {
-        ERROR("Handshake failed - %s", gnutls_strerror(err));
+        SFL_ERR("Handshake failed - %s", gnutls_strerror(err));
         goto out;
     }
     /* Obtain the server certificate chain. The server certificate
      * itself is stored in the first element of the array. */
     certs = gnutls_certificate_get_peers(session, &certslen);
     if (certs == NULL || certslen == 0) {
-        ERROR("Could not obtain peer certificate - %s", gnutls_strerror(err));
+        SFL_ERR("Could not obtain peer certificate - %s", gnutls_strerror(err));
         goto out;
     }
 
     /* Validate the certificate chain. */
     err = gnutls_certificate_verify_peers2(session, &status);
     if (err != GNUTLS_E_SUCCESS) {
-        ERROR("Could not verify the certificate chain - %s", gnutls_strerror(err));
+        SFL_ERR("Could not verify the certificate chain - %s", gnutls_strerror(err));
         goto out;
     }
     if (status != 0) {
@@ -608,11 +608,11 @@ int verifyHostnameCertificate(const char *host, const uint16_t port)
         err = -1;
 #endif
         if (err == 0) {
-            ERROR("Certificate validation failed - %s\n", msg.data);
+            SFL_ERR("Certificate validation failed - %s\n", msg.data);
             gnutls_free(msg.data);
             goto out;
         } else {
-            ERROR("Certificate validation failed with code 0x%x.", status);
+            SFL_ERR("Certificate validation failed with code 0x%x.", status);
             goto out;
         }
     }
@@ -624,7 +624,7 @@ int verifyHostnameCertificate(const char *host, const uint16_t port)
 
     err = gnutls_x509_crt_init(&cert);
     if (err != GNUTLS_E_SUCCESS) {
-        ERROR("Could not init certificate - %s", gnutls_strerror(err));
+        SFL_ERR("Could not init certificate - %s", gnutls_strerror(err));
         goto out;
     }
 
@@ -633,13 +633,13 @@ int verifyHostnameCertificate(const char *host, const uint16_t port)
     if (err != GNUTLS_E_SUCCESS)
         err = gnutls_x509_crt_import(cert, certs, GNUTLS_X509_FMT_DER);
     if (err != GNUTLS_E_SUCCESS) {
-        ERROR("Could not read peer certificate - %s", gnutls_strerror(err));
+        SFL_ERR("Could not read peer certificate - %s", gnutls_strerror(err));
         goto out;
     }
     /* Finally check if the hostnames match. */
     err = gnutls_x509_crt_check_hostname(cert, host);
     if (err == 0) {
-        ERROR("Hostname %s does not match certificate.", host);
+        SFL_ERR("Hostname %s does not match certificate.", host);
         goto out;
     }
 
@@ -647,16 +647,16 @@ int verifyHostnameCertificate(const char *host, const uint16_t port)
     snprintf(buf, sizeof(buf), "GET / HTTP/1.0\r\nHost: %s\r\n\r\n", host);
     err = gnutls_record_send(session, buf, strlen(buf));
     if (err < 0) {
-        ERROR("Send failed - %s", gnutls_strerror(err));
+        SFL_ERR("Send failed - %s", gnutls_strerror(err));
         goto out;
     }
     err = gnutls_record_recv(session, buf, sizeof(buf));
     if (err < 0) {
-        ERROR("Recv failed - %s", gnutls_strerror(err));
+        SFL_ERR("Recv failed - %s", gnutls_strerror(err));
         goto out;
     }
 
-    DEBUG("Hostname %s seems to point to a valid server.", host);
+    SFL_DBG("Hostname %s seems to point to a valid server.", host);
     res = 0;
 out:
     if (session) {
diff --git a/daemon/src/threadloop.cpp b/daemon/src/threadloop.cpp
index a08a49f51ff7d365e3b1207afa58443b5c993101..f2950d3aba060046d9e7ccaed4a03e55dab5d740 100644
--- a/daemon/src/threadloop.cpp
+++ b/daemon/src/threadloop.cpp
@@ -40,10 +40,10 @@ void ThreadLoop::mainloop()
                 process_();
             cleanup_();
         } else {
-            ERROR("setup failed");
+            SFL_ERR("setup failed");
         }
     } catch (const ThreadLoopException &e) {
-        ERROR("%s", e.what());
+        SFL_ERR("%s", e.what());
     }
 }
 
@@ -56,7 +56,7 @@ ThreadLoop::ThreadLoop(const std::function<bool()> &setup,
 ThreadLoop::~ThreadLoop()
 {
     if (isRunning()) {
-        ERROR("join() should be explicitly called in owner's destructor");
+        SFL_ERR("join() should be explicitly called in owner's destructor");
         join();
     }
 }
@@ -69,7 +69,7 @@ void ThreadLoop::start()
             thread_.join();
         thread_ = std::thread(&ThreadLoop::mainloop, this);
     } else {
-        ERROR("Thread already started");
+        SFL_ERR("Thread already started");
     }
 }
 
diff --git a/daemon/src/threadloop.h b/daemon/src/threadloop.h
index 431dacd8cfc9b287f35d4b4f5dcd80280bf8c2db..80de6be579c79fdf3239575fc25f5ea5eaf915a3 100644
--- a/daemon/src/threadloop.h
+++ b/daemon/src/threadloop.h
@@ -40,7 +40,7 @@
 // FIXME: this is ugly
 // If condition A is false, print the error message in M and exit thread
 #define EXIT_IF_FAIL(A, M, ...) if (!(A)) { \
-        ERROR(M, ##__VA_ARGS__); loop_.exit(); }
+        SFL_ERR(M, ##__VA_ARGS__); loop_.exit(); }
 
 struct ThreadLoopException : public std::runtime_error {
     ThreadLoopException() : std::runtime_error("ThreadLoopException") {}
diff --git a/daemon/src/video/libav_utils.cpp b/daemon/src/video/libav_utils.cpp
index 8c9c04cdc22216acbd59c426d66dae5ffe5bf5e5..bb1fb5603d7e806fa665f0b669a30771da510a03 100644
--- a/daemon/src/video/libav_utils.cpp
+++ b/daemon/src/video/libav_utils.cpp
@@ -55,7 +55,7 @@ findInstalledVideoCodecs()
         if (std::find(libav_codecs.begin(), libav_codecs.end(), it.second) != libav_codecs.end())
             installed_video_codecs_.push_back(it.first);
         else
-            ERROR("Didn't find \"%s\" encoder", it.second.c_str());
+            SFL_ERR("Didn't find \"%s\" encoder", it.second.c_str());
     }
 }
 
diff --git a/daemon/src/video/shm_sink.cpp b/daemon/src/video/shm_sink.cpp
index 23bf3ce290a44b1858147ab653d7da9c36374e26..0152e321e97057063894fb82bd989ae712369b4e 100644
--- a/daemon/src/video/shm_sink.cpp
+++ b/daemon/src/video/shm_sink.cpp
@@ -73,7 +73,7 @@ SHMSink::~SHMSink()
 bool SHMSink::start()
 {
     if (fd_ != -1) {
-        ERROR("fd must be -1");
+        SFL_ERR("fd must be -1");
         return false;
     }
 
@@ -83,7 +83,7 @@ bool SHMSink::start()
     if (not shm_name_.empty()) {
         fd_ = shm_open(shm_name_.c_str(), flags, perms);
         if (fd_ < 0) {
-            ERROR("could not open shm area \"%s\"", shm_name_.c_str());
+            SFL_ERR("could not open shm area \"%s\"", shm_name_.c_str());
             strErr();
             return false;
         }
@@ -100,13 +100,13 @@ bool SHMSink::start()
         }
     }
 
-    DEBUG("Using name %s", shm_name_.c_str());
+    SFL_DBG("Using name %s", shm_name_.c_str());
     opened_name_ = shm_name_;
 
     shm_area_len_ = sizeof(SHMHeader);
 
     if (ftruncate(fd_, shm_area_len_)) {
-        ERROR("Could not make shm area large enough for header");
+        SFL_ERR("Could not make shm area large enough for header");
         strErr();
         return false;
     }
@@ -114,17 +114,17 @@ bool SHMSink::start()
     shm_area_ = static_cast<SHMHeader*>(mmap(NULL, shm_area_len_, PROT_READ | PROT_WRITE, MAP_SHARED, fd_, 0));
 
     if (shm_area_ == MAP_FAILED) {
-        ERROR("Could not map shm area, mmap failed");
+        SFL_ERR("Could not map shm area, mmap failed");
         return false;
     }
 
     memset(shm_area_, 0, shm_area_len_);
     if (sem_init(&shm_area_->notification, 1, 0) != 0) {
-        ERROR("sem_init: notification initialization failed");
+        SFL_ERR("sem_init: notification initialization failed");
         return false;
     }
     if (sem_init(&shm_area_->mutex, 1, 1) != 0) {
-        ERROR("sem_init: mutex initialization failed");
+        SFL_ERR("sem_init: mutex initialization failed");
         return false;
     }
     return true;
@@ -158,13 +158,13 @@ bool SHMSink::resize_area(size_t desired_length)
     shm_unlock();
 
     if (munmap(shm_area_, shm_area_len_)) {
-        ERROR("Could not unmap shared area");
+        SFL_ERR("Could not unmap shared area");
         strErr();
         return false;
     }
 
     if (ftruncate(fd_, desired_length)) {
-        ERROR("Could not resize shared area");
+        SFL_ERR("Could not resize shared area");
         strErr();
         return false;
     }
@@ -174,7 +174,7 @@ bool SHMSink::resize_area(size_t desired_length)
 
     if (shm_area_ == MAP_FAILED) {
         shm_area_ = 0;
-        ERROR("Could not remap shared area");
+        SFL_ERR("Could not remap shared area");
         return false;
     }
 
@@ -209,7 +209,7 @@ void SHMSink::render_frame(VideoFrame& src)
     shm_lock();
 
     if (!resize_area(sizeof(SHMHeader) + bytes)) {
-        ERROR("Could not resize area");
+        SFL_ERR("Could not resize area");
         return;
     }
 
@@ -221,7 +221,7 @@ void SHMSink::render_frame(VideoFrame& src)
     const std::chrono::duration<double> seconds = currentTime - lastFrameDebug_;
     frameCount_++;
     if (seconds.count() > 1) {
-        DEBUG("%s: FPS %f", shm_name_.c_str(), frameCount_ / seconds.count());
+        SFL_DBG("%s: FPS %f", shm_name_.c_str(), frameCount_ / seconds.count());
         frameCount_ = 0;
         lastFrameDebug_ = currentTime;
     }
@@ -238,7 +238,7 @@ void SHMSink::render_callback(VideoProvider &provider, size_t bytes)
     shm_lock();
 
     if (!resize_area(sizeof(SHMHeader) + bytes)) {
-        ERROR("Could not resize area");
+        SFL_ERR("Could not resize area");
         return;
     }
 
diff --git a/daemon/src/video/socket_pair.cpp b/daemon/src/video/socket_pair.cpp
index 344797f558e8878e4b400c6887c34387eaf3a2ff..6c50ff5466f0db1fd0b1c2b59ebcd106eecc0a24 100644
--- a/daemon/src/video/socket_pair.cpp
+++ b/daemon/src/video/socket_pair.cpp
@@ -74,7 +74,7 @@ addrinfo* udp_resolve_host(const char *node, int service)
     hints.ai_flags = AI_PASSIVE;
     if ((error = getaddrinfo(node, sport, &hints, &res))) {
         res = NULL;
-        ERROR("%s\n", gai_strerror(error));
+        SFL_ERR("%s\n", gai_strerror(error));
     }
 
     return res;
@@ -107,7 +107,7 @@ udp_socket_create(sockaddr_storage *addr, socklen_t *addr_len, int local_port)
     for (res = res0; res; res=res->ai_next) {
         udp_fd = socket(res->ai_family, SOCK_DGRAM | SOCK_NONBLOCK, 0);
         if (udp_fd != -1) break;
-        ERROR("socket error");
+        SFL_ERR("socket error");
     }
 
     if (udp_fd < 0) {
@@ -122,7 +122,7 @@ udp_socket_create(sockaddr_storage *addr, socklen_t *addr_len, int local_port)
     // bind socket so that we send from and receive
     // on local port
     if (bind(udp_fd, reinterpret_cast<sockaddr*>(addr), *addr_len) < 0) {
-        ERROR("Bind failed");
+        SFL_ERR("Bind failed");
         strErr();
         close(udp_fd);
         udp_fd = -1;
@@ -184,7 +184,7 @@ void SocketPair::openSockets(const char *uri, int local_rtp_port)
 #if HAVE_SDP_CUSTOM_IO
     const int local_rtcp_port = local_rtp_port + 1;
 #else
-    WARN("libavformat too old for socket reuse, using random source ports");
+    SFL_WARN("libavformat too old for socket reuse, using random source ports");
     local_rtp_port = 0;
     const int local_rtcp_port = 0;
 #endif
@@ -223,7 +223,7 @@ int SocketPair::readCallback(void *opaque, uint8_t *buf, int buf_size)
 
     for(;;) {
         if (context->interrupted_) {
-            ERROR("interrupted");
+            SFL_ERR("interrupted");
             return -EINTR;
         }
 
diff --git a/daemon/src/video/v4l2/video_device_impl.cpp b/daemon/src/video/v4l2/video_device_impl.cpp
index 45ce19b9adca996b5b4ed40adcafeffdd911ff49..48323c412f903d7c4beaed07ed707dc6776e3c2c 100644
--- a/daemon/src/video/v4l2/video_device_impl.cpp
+++ b/daemon/src/video/v4l2/video_device_impl.cpp
@@ -238,7 +238,7 @@ void VideoV4l2Size::getFrameRates(int fd, unsigned int pixel_format)
 
     if (ioctl(fd, VIDIOC_ENUM_FRAMEINTERVALS, &frmival)) {
         rates_.push_back(25);
-        ERROR("could not query frame interval for size");
+        SFL_ERR("could not query frame interval for size");
         return;
     }
 
@@ -252,12 +252,12 @@ void VideoV4l2Size::getFrameRates(int fd, unsigned int pixel_format)
         case V4L2_FRMIVAL_TYPE_CONTINUOUS:
             rates_.push_back(25);
             // TODO
-            ERROR("Continuous Frame Intervals not supported");
+            SFL_ERR("Continuous Frame Intervals not supported");
             break;
         case V4L2_FRMIVAL_TYPE_STEPWISE:
             rates_.push_back(25);
             // TODO
-            ERROR("Stepwise Frame Intervals not supported");
+            SFL_ERR("Stepwise Frame Intervals not supported");
             break;
     }
 }
@@ -332,10 +332,10 @@ VideoV4l2Channel::getSizes(int fd, unsigned int pixelformat)
                 // from 1x1 to 2000x2000
                 // We should limit to a list of known standard sizes
             case V4L2_FRMSIZE_TYPE_CONTINUOUS:
-                ERROR("Continuous Frame sizes not supported");
+                SFL_ERR("Continuous Frame sizes not supported");
                 break;
             case V4L2_FRMSIZE_TYPE_STEPWISE:
-                ERROR("Stepwise Frame sizes not supported");
+                SFL_ERR("Stepwise Frame sizes not supported");
                 break;
         }
     }
diff --git a/daemon/src/video/v4l2/video_device_monitor_impl.cpp b/daemon/src/video/v4l2/video_device_monitor_impl.cpp
index 1216be0be315f1baa0f7036e9065255eda600547..ba094d58292cdf380764ae51576219e586d3692f 100644
--- a/daemon/src/video/v4l2/video_device_monitor_impl.cpp
+++ b/daemon/src/video/v4l2/video_device_monitor_impl.cpp
@@ -140,7 +140,7 @@ VideoDeviceMonitorImpl::VideoDeviceMonitorImpl(VideoDeviceMonitor* monitor) :
                 try {
                     monitor_->addDevice(string(devpath));
                 } catch (const std::runtime_error &e) {
-                    ERROR("%s", e.what());
+                    SFL_ERR("%s", e.what());
                 }
             }
         }
@@ -152,7 +152,7 @@ VideoDeviceMonitorImpl::VideoDeviceMonitorImpl(VideoDeviceMonitor* monitor) :
 
 udev_failed:
 
-    ERROR("udev enumeration failed");
+    SFL_ERR("udev enumeration failed");
 
     if (udev_mon_)
         udev_monitor_unref(udev_mon_);
@@ -168,7 +168,7 @@ udev_failed:
         try {
             monitor_->addDevice(ss.str());
         } catch (const std::runtime_error &e) {
-            ERROR("%s", e.what());
+            SFL_ERR("%s", e.what());
             return;
         }
     }
@@ -220,14 +220,14 @@ void VideoDeviceMonitorImpl::run()
                     const char *node = udev_device_get_devnode(dev);
                     const char *action = udev_device_get_action(dev);
                     if (!strcmp(action, "add")) {
-                        DEBUG("udev: adding %s", node);
+                        SFL_DBG("udev: adding %s", node);
                         try {
                             monitor_->addDevice(node);
                         } catch (const std::runtime_error &e) {
-                            ERROR("%s", e.what());
+                            SFL_ERR("%s", e.what());
                         }
                     } else if (!strcmp(action, "remove")) {
-                        DEBUG("udev: removing %s", node);
+                        SFL_DBG("udev: removing %s", node);
                         monitor_->removeDevice(string(node));
                     }
                     udev_device_unref(dev);
@@ -237,12 +237,12 @@ void VideoDeviceMonitorImpl::run()
             case -1:
                 if (errno == EAGAIN)
                     continue;
-                ERROR("udev monitoring thread: select failed (%m)");
+                SFL_ERR("udev monitoring thread: select failed (%m)");
                 probing_ = false;
                 return;
 
             default:
-                ERROR("select() returned %d (%m)", ret);
+                SFL_ERR("select() returned %d (%m)", ret);
                 probing_ = false;
                 return;
         }
diff --git a/daemon/src/video/video_decoder.cpp b/daemon/src/video/video_decoder.cpp
index 9136d8de7b5b103d1ebcd2f8e10d84a286d7ac05..bb67e29b873b6814b98ace41d2d1d050b88ba0b0 100644
--- a/daemon/src/video/video_decoder.cpp
+++ b/daemon/src/video/video_decoder.cpp
@@ -89,7 +89,7 @@ int VideoDecoder::openInput(const std::string &source_str,
     AVInputFormat *iformat = av_find_input_format(format_str.c_str());
 
     if (!iformat)
-        WARN("Cannot find format \"%s\"", format_str.c_str());
+        SFL_WARN("Cannot find format \"%s\"", format_str.c_str());
 
     int ret = avformat_open_input(&inputCtx_, source_str.c_str(), iformat,
                                   options_ ? &options_ : NULL);
@@ -97,9 +97,9 @@ int VideoDecoder::openInput(const std::string &source_str,
     if (ret) {
         char errbuf[64];
         av_strerror(ret, errbuf, sizeof(errbuf));
-        ERROR("avformat_open_input failed: %s", errbuf);
+        SFL_ERR("avformat_open_input failed: %s", errbuf);
     } else {
-        DEBUG("Using format %s", format_str.c_str());
+        SFL_DBG("Using format %s", format_str.c_str());
     }
 
     return ret;
@@ -130,7 +130,7 @@ int VideoDecoder::setupFromVideoData()
 
     inputCtx_->max_analyze_duration = MAX_ANALYZE_DURATION * AV_TIME_BASE;
 
-    DEBUG("Finding stream info");
+    SFL_DBG("Finding stream info");
 #if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(53, 8, 0)
     ret = av_find_stream_info(inputCtx_);
 #else
@@ -148,7 +148,7 @@ int VideoDecoder::setupFromVideoData()
             errBuf[0] = '\0';
 
         // always fail here
-        ERROR("Could not find stream info: %s", errBuf);
+        SFL_ERR("Could not find stream info: %s", errBuf);
         return -1;
     }
 
@@ -158,27 +158,27 @@ int VideoDecoder::setupFromVideoData()
             streamIndex_ = i;
 
     if (streamIndex_ == -1) {
-        ERROR("Could not find video stream");
+        SFL_ERR("Could not find video stream");
         return -1;
     }
 
     // Get a pointer to the codec context for the video stream
     decoderCtx_ = inputCtx_->streams[streamIndex_]->codec;
     if (decoderCtx_ == 0) {
-        ERROR("Decoder context is NULL");
+        SFL_ERR("Decoder context is NULL");
         return -1;
     }
 
     // find the decoder for the video stream
     inputDecoder_ = avcodec_find_decoder(decoderCtx_->codec_id);
     if (!inputDecoder_) {
-        ERROR("Unsupported codec");
+        SFL_ERR("Unsupported codec");
         return -1;
     }
 
     decoderCtx_->thread_count = 1;
     if (emulateRate_) {
-        DEBUG("Using framerate emulation");
+        SFL_DBG("Using framerate emulation");
         startTime_ = av_gettime();
     }
 
@@ -191,7 +191,7 @@ int VideoDecoder::setupFromVideoData()
     ret = avcodec_open2(decoderCtx_, inputDecoder_, NULL);
 #endif
     if (ret) {
-        ERROR("Could not open codec");
+        SFL_ERR("Could not open codec");
         return -1;
     }
 
@@ -210,7 +210,7 @@ VideoDecoder::decode(VideoFrame& result, VideoPacket& video_packet)
     } else if (ret < 0) {
         char errbuf[64];
         av_strerror(ret, errbuf, sizeof(errbuf));
-        ERROR("Couldn't read frame: %s\n", errbuf);
+        SFL_ERR("Couldn't read frame: %s\n", errbuf);
         return Status::ReadError;
     }
 
diff --git a/daemon/src/video/video_device_monitor.cpp b/daemon/src/video/video_device_monitor.cpp
index 181bea85915bbd08f8459c0327b2d8a8b7924293..5e938b3445f41f6a3f45a71f7f647ebf68c250df 100644
--- a/daemon/src/video/video_device_monitor.cpp
+++ b/daemon/src/video/video_device_monitor.cpp
@@ -155,7 +155,7 @@ static void
 notify()
 {
     if (!ManagerImpl::initialized) {
-        WARN("Manager not initialized yet");
+        SFL_WARN("Manager not initialized yet");
         return;
     }
 
diff --git a/daemon/src/video/video_encoder.cpp b/daemon/src/video/video_encoder.cpp
index b5d67a3fb63cb6cdc14feb0d255b4f4ff8f48543..724c57ac476e3959a1aa9c927890047ddc47dbf7 100644
--- a/daemon/src/video/video_encoder.cpp
+++ b/daemon/src/video/video_encoder.cpp
@@ -110,7 +110,7 @@ VideoEncoder::openOutput(const char *enc_name, const char *short_name,
     AVOutputFormat *oformat = av_guess_format(short_name, filename, mime_type);
 
     if (!oformat) {
-        ERROR("Unable to find a suitable output format for %s", filename);
+        SFL_ERR("Unable to find a suitable output format for %s", filename);
         throw VideoEncoderException("No output format");
     }
 
@@ -122,7 +122,7 @@ VideoEncoder::openOutput(const char *enc_name, const char *short_name,
     /* find the video encoder */
     outputEncoder_ = avcodec_find_encoder_by_name(enc_name);
     if (!outputEncoder_) {
-        ERROR("Encoder \"%s\" not found!", enc_name);
+        SFL_ERR("Encoder \"%s\" not found!", enc_name);
         throw VideoEncoderException("No output encoder");
     }
 
@@ -203,7 +203,7 @@ void
 VideoEncoder::startIO()
 {
     if (avformat_write_header(outputCtx_, options_ ? &options_ : NULL)) {
-        ERROR("Could not write header for output file... check codec parameters");
+        SFL_ERR("Could not write header for output file... check codec parameters");
         throw VideoEncoderException("Failed to write output file header");
     }
 
@@ -215,7 +215,7 @@ print_averror(const char *funcname, int err)
 {
     char errbuf[64];
     av_strerror(err, errbuf, sizeof(errbuf));
-    ERROR("%s failed: %s", funcname, errbuf);
+    SFL_ERR("%s failed: %s", funcname, errbuf);
 }
 
 int VideoEncoder::encode(VideoFrame &input, bool is_keyframe, int64_t frame_number)
@@ -319,7 +319,7 @@ int VideoEncoder::flush()
 
     ret = avcodec_encode_video2(encoderCtx_, &pkt, NULL, &got_packet);
     if (ret != 0) {
-        ERROR("avcodec_encode_video failed");
+        SFL_ERR("avcodec_encode_video failed");
         av_free_packet(&pkt);
         return -1;
     }
@@ -328,13 +328,13 @@ int VideoEncoder::flush()
         // write the compressed frame
         ret = av_write_frame(outputCtx_, &pkt);
         if (ret < 0)
-            ERROR("write_frame failed");
+            SFL_ERR("write_frame failed");
     }
 #else
     ret = avcodec_encode_video(encoderCtx_, encoderBuffer_,
                                encoderBufferSize_, NULL);
     if (ret < 0) {
-        ERROR("avcodec_encode_video failed");
+        SFL_ERR("avcodec_encode_video failed");
         av_free_packet(&pkt);
         return ret;
     }
@@ -345,7 +345,7 @@ int VideoEncoder::flush()
     // write the compressed frame
     ret = av_write_frame(outputCtx_, &pkt);
     if (ret < 0)
-        ERROR("write_frame failed");
+        SFL_ERR("write_frame failed");
 #endif
     av_free_packet(&pkt);
 
@@ -367,7 +367,7 @@ void VideoEncoder::print_sdp(std::string &sdp_)
         line = line.substr(0, line.length() - 1);
         sdp_ += line + "\n";
     }
-    DEBUG("Sending SDP: \n%s", sdp_.c_str());
+    SFL_DBG("Sending SDP: \n%s", sdp_.c_str());
 }
 
 void VideoEncoder::prepareEncoderContext()
@@ -383,7 +383,7 @@ void VideoEncoder::prepareEncoderContext()
     // set some encoder settings here
     encoderCtx_->bit_rate = 1000 * atoi(av_dict_get(options_, "bitrate",
                                                     NULL, 0)->value);
-    DEBUG("Using bitrate %d", encoderCtx_->bit_rate);
+    SFL_DBG("Using bitrate %d", encoderCtx_->bit_rate);
 
     // resolution must be a multiple of two
     char *width = av_dict_get(options_, "width", NULL, 0)->value;
@@ -411,10 +411,10 @@ void VideoEncoder::forcePresetX264()
 {
     const char *speedPreset = "ultrafast";
     if (av_opt_set(encoderCtx_->priv_data, "preset", speedPreset, 0))
-        WARN("Failed to set x264 preset '%s'", speedPreset);
+        SFL_WARN("Failed to set x264 preset '%s'", speedPreset);
     const char *tune = "zerolatency";
     if (av_opt_set(encoderCtx_->priv_data, "tune", tune, 0))
-        WARN("Failed to set x264 tune '%s'", tune);
+        SFL_WARN("Failed to set x264 tune '%s'", tune);
 }
 
 void VideoEncoder::extractProfileLevelID(const std::string &parameters,
@@ -462,7 +462,7 @@ void VideoEncoder::extractProfileLevelID(const std::string &parameters,
                 ctx->profile |= FF_PROFILE_H264_INTRA;
             break;
     }
-    DEBUG("Using profile %x and level %d", ctx->profile, ctx->level);
+    SFL_DBG("Using profile %x and level %d", ctx->profile, ctx->level);
 }
 
 }
diff --git a/daemon/src/video/video_input.cpp b/daemon/src/video/video_input.cpp
index ea08a20c7186e7ea4a6e9653ea4d8d9a7a9dc810..713707b40fc824e6f6fd45f95ea87d7dcf7c05a9 100644
--- a/daemon/src/video/video_input.cpp
+++ b/daemon/src/video/video_input.cpp
@@ -60,11 +60,11 @@ bool VideoInput::setup()
 {
     /* Sink setup */
     if (!sink_.start()) {
-        ERROR("Cannot start shared memory sink");
+        SFL_ERR("Cannot start shared memory sink");
         return false;
     }
     if (not attach(&sink_))
-        WARN("Failed to attach sink");
+        SFL_WARN("Failed to attach sink");
 
     return true;
 }
@@ -90,7 +90,7 @@ void VideoInput::process()
         /* Signal the client about the new sink */
         Manager::instance().getVideoManager()->startedDecoding(sinkID_, sink_.openedName(),
                 decoder_->getWidth(), decoder_->getHeight(), false);
-        DEBUG("LOCAL: shm sink <%s> started: size = %dx%d",
+        SFL_DBG("LOCAL: shm sink <%s> started: size = %dx%d",
               sink_.openedName().c_str(), decoder_->getWidth(),
               decoder_->getHeight());
     }
@@ -152,7 +152,7 @@ VideoInput::createDecoder()
     decoder_->setInterruptCallback(interruptCb, this);
 
     if (decoder_->openInput(input_, format_) < 0) {
-        ERROR("Could not open input \"%s\"", input_.c_str());
+        SFL_ERR("Could not open input \"%s\"", input_.c_str());
         delete decoder_;
         decoder_ = nullptr;
         return;
@@ -160,7 +160,7 @@ VideoInput::createDecoder()
 
     /* Data available, finish the decoding */
     if (decoder_->setupFromVideoData() < 0) {
-        ERROR("decoder IO startup failed");
+        SFL_ERR("decoder IO startup failed");
         delete decoder_;
         decoder_ = nullptr;
         return;
@@ -228,7 +228,7 @@ VideoInput::initFile(std::string path)
 
     /* File exists? */
     if (access(path.c_str(), R_OK) != 0) {
-        ERROR("file '%s' unavailable\n", path.c_str());
+        SFL_ERR("file '%s' unavailable\n", path.c_str());
         return false;
     }
 
@@ -242,7 +242,7 @@ VideoInput::initFile(std::string path)
         format_ = "image2";
         decOpts_["framerate"] = "1";
     } else {
-        WARN("Guessing file type for %s", path.c_str());
+        SFL_WARN("Guessing file type for %s", path.c_str());
         // FIXME: proper parsing of FPS etc. should be done in
         // VideoDecoder, not here.
         decOpts_["framerate"] = "25";
@@ -254,10 +254,10 @@ VideoInput::initFile(std::string path)
 bool
 VideoInput::switchInput(const std::string& resource)
 {
-    DEBUG("MRL: '%s'", resource.c_str());
+    SFL_DBG("MRL: '%s'", resource.c_str());
 
     if (switchPending_) {
-        ERROR("Video switch already requested");
+        SFL_ERR("Video switch already requested");
         return false;
     }
 
@@ -303,7 +303,7 @@ VideoInput::switchInput(const std::string& resource)
             loop_.start();
     }
     else
-        ERROR("Failed to init input for MRL '%s'\n", resource.c_str());
+        SFL_ERR("Failed to init input for MRL '%s'\n", resource.c_str());
 
     return valid;
 }
diff --git a/daemon/src/video/video_mixer.cpp b/daemon/src/video/video_mixer.cpp
index 4aa7d3547109d4a802410d60d0f5817c4466c985..27c22e4764a57d5f6945f51e4109631302eab2b9 100644
--- a/daemon/src/video/video_mixer.cpp
+++ b/daemon/src/video/video_mixer.cpp
@@ -122,7 +122,7 @@ void VideoMixer::process()
 
     VideoFrame& output = getNewFrame();
     if (!output.allocBuffer(width_, height_, VIDEO_PIXFMT_YUV420P)) {
-        ERROR("VideoFrame::allocBuffer() failed");
+        SFL_ERR("VideoFrame::allocBuffer() failed");
         return;
     }
 
@@ -190,11 +190,11 @@ void VideoMixer::start_sink()
     if (sink_.start()) {
         if (this->attach(&sink_)) {
             Manager::instance().getVideoManager()->startedDecoding(id_, sink_.openedName(), width_, height_, true);
-            DEBUG("MX: shm sink <%s> started: size = %dx%d",
+            SFL_DBG("MX: shm sink <%s> started: size = %dx%d",
                   sink_.openedName().c_str(), width_, height_);
         }
     } else
-        WARN("MX: sink startup failed");
+        SFL_WARN("MX: sink startup failed");
 }
 
 void VideoMixer::stop_sink()
diff --git a/daemon/src/video/video_receive_thread.cpp b/daemon/src/video/video_receive_thread.cpp
index 8937e021b9ff35445ef8bc246d9ad1e123159b94..fac2c2fb997896fdb1664d4d66cc86255fed59ca 100644
--- a/daemon/src/video/video_receive_thread.cpp
+++ b/daemon/src/video/video_receive_thread.cpp
@@ -106,7 +106,7 @@ bool VideoReceiveThread::setup()
         // custom_io so the SDP demuxer will not open any UDP connections
         args_["sdp_flags"] = "custom_io";
 #else
-        WARN("libavformat too old for custom SDP demuxing");
+        SFL_WARN("libavformat too old for custom SDP demuxing");
 #endif
 
         EXIT_IF_FAIL(not stream_.str().empty(), "No SDP loaded");
@@ -198,15 +198,15 @@ bool VideoReceiveThread::decodeFrame()
             return true;
 
         case VideoDecoder::Status::DecodeError:
-            WARN("decoding failure, trying to reset decoder...");
+            SFL_WARN("decoding failure, trying to reset decoder...");
             delete videoDecoder_;
             if (!setup()) {
-                ERROR("fatal error, rx thread re-setup failed");
+                SFL_ERR("fatal error, rx thread re-setup failed");
                 loop_.stop();
                 break;
             }
             if (!videoDecoder_->setupFromVideoData()) {
-                ERROR("fatal error, v-decoder setup failed");
+                SFL_ERR("fatal error, v-decoder setup failed");
                 loop_.stop();
                 break;
             }
@@ -215,7 +215,7 @@ bool VideoReceiveThread::decodeFrame()
             break;
 
         case VideoDecoder::Status::ReadError:
-            ERROR("fatal error, read failed");
+            SFL_ERR("fatal error, read failed");
             loop_.stop();
 
         default:
@@ -233,7 +233,7 @@ void VideoReceiveThread::enterConference()
 
     if (detach(&sink_)) {
         Manager::instance().getVideoManager()->stoppedDecoding(id_, sink_.openedName(), false);
-        DEBUG("RX: shm sink <%s> detached", sink_.openedName().c_str());
+        SFL_DBG("RX: shm sink <%s> detached", sink_.openedName().c_str());
     }
 }
 
@@ -245,7 +245,7 @@ void VideoReceiveThread::exitConference()
     if (dstWidth_ > 0 && dstHeight_ > 0) {
         if (attach(&sink_)) {
             Manager::instance().getVideoManager()->startedDecoding(id_, sink_.openedName(), dstWidth_, dstHeight_, false);
-            DEBUG("RX: shm sink <%s> started: size = %dx%d",
+            SFL_DBG("RX: shm sink <%s> started: size = %dx%d",
                   sink_.openedName().c_str(), dstWidth_, dstHeight_);
         }
     }
diff --git a/daemon/src/video/video_rtp_session.cpp b/daemon/src/video/video_rtp_session.cpp
index 6b46dc3cb2a30cf3a6187a96c1ec7b3851d9e333..93dc73d1149dfdaedfcd8c9f2baae63757f27391 100644
--- a/daemon/src/video/video_rtp_session.cpp
+++ b/daemon/src/video/video_rtp_session.cpp
@@ -65,35 +65,35 @@ void VideoRtpSession::updateSDP(const Sdp &sdp)
     // if port has changed
     if (not desc.empty() and desc != rxArgs_["receiving_sdp"]) {
         rxArgs_["receiving_sdp"] = desc;
-        DEBUG("Updated incoming SDP to:\n%s",
+        SFL_DBG("Updated incoming SDP to:\n%s",
               rxArgs_["receiving_sdp"].c_str());
     }
 
     if (desc.empty()) {
-        DEBUG("Video is inactive");
+        SFL_DBG("Video is inactive");
         receiving_ = false;
         sending_ = false;
     } else if (desc.find("sendrecv") != string::npos) {
-        DEBUG("Sending and receiving video");
+        SFL_DBG("Sending and receiving video");
         receiving_ = true;
         sending_ = true;
     } else if (desc.find("inactive") != string::npos) {
-        DEBUG("Video is inactive");
+        SFL_DBG("Video is inactive");
         receiving_ = false;
         sending_ = false;
     } else if (desc.find("sendonly") != string::npos) {
-        DEBUG("Receiving video disabled, video set to sendonly");
+        SFL_DBG("Receiving video disabled, video set to sendonly");
         receiving_ = false;
         sending_ = true;
     } else if (desc.find("recvonly") != string::npos) {
-        DEBUG("Sending video disabled, video set to recvonly");
+        SFL_DBG("Sending video disabled, video set to recvonly");
         sending_ = false;
         receiving_ = true;
     }
     // even if it says sendrecv or recvonly, our peer may disable video by
     // setting the port to 0
     if (desc.find("m=video 0") != string::npos) {
-        DEBUG("Receiving video disabled, port was set to 0");
+        SFL_DBG("Receiving video disabled, port was set to 0");
         receiving_ = false;
     }
 
@@ -106,7 +106,7 @@ void VideoRtpSession::updateDestination(const string &destination,
 {
     std::lock_guard<std::recursive_mutex> lock(mutex_);
     if (destination.empty()) {
-        ERROR("Destination is empty, ignoring");
+        SFL_ERR("Destination is empty, ignoring");
         return;
     }
 
@@ -115,15 +115,15 @@ void VideoRtpSession::updateDestination(const string &destination,
     // if destination has changed
     if (tmp.str() != txArgs_["destination"]) {
         if (sender_) {
-            ERROR("Video is already being sent");
+            SFL_ERR("Video is already being sent");
             return;
         }
         txArgs_["destination"] = tmp.str();
-        DEBUG("updated dest to %s",  txArgs_["destination"].c_str());
+        SFL_DBG("updated dest to %s",  txArgs_["destination"].c_str());
     }
 
     if (port == 0) {
-        DEBUG("Sending video disabled, port was set to 0");
+        SFL_DBG("Sending video disabled, port was set to 0");
         sending_ = false;
     }
 }
@@ -136,13 +136,13 @@ void VideoRtpSession::startSender()
                 videoLocal_->detach(sender_.get());
             if (videoMixer_)
                 videoMixer_->detach(sender_.get());
-            WARN("Restarting video sender");
+            SFL_WARN("Restarting video sender");
         }
 
         try {
             sender_.reset(new VideoSender(txArgs_, *socketPair_));
         } catch (const VideoEncoderException &e) {
-            ERROR("%s", e.what());
+            SFL_ERR("%s", e.what());
             sending_ = false;
         }
     }
@@ -152,13 +152,13 @@ void VideoRtpSession::startReceiver()
 {
     if (receiving_) {
         if (receiveThread_)
-            WARN("restarting video receiver");
+            SFL_WARN("restarting video receiver");
         receiveThread_.reset(new VideoReceiveThread(callID_, rxArgs_));
         receiveThread_->setRequestKeyFrameCallback(&SIPVoIPLink::enqueueKeyframeRequest);
         receiveThread_->addIOContext(*socketPair_);
         receiveThread_->startLoop();
     } else {
-        DEBUG("Video receiving disabled");
+        SFL_DBG("Video receiving disabled");
         if (receiveThread_)
             receiveThread_->detach(videoMixer_.get());
         receiveThread_.reset();
@@ -177,7 +177,7 @@ void VideoRtpSession::start(int localPort)
     try {
         socketPair_.reset(new SocketPair(txArgs_["destination"].c_str(), localPort));
     } catch (const std::runtime_error &e) {
-        ERROR("Socket creation failed on port %d: %s", localPort, e.what());
+        SFL_ERR("Socket creation failed on port %d: %s", localPort, e.what());
         return;
     }
 
diff --git a/daemon/src/video/video_scaler.cpp b/daemon/src/video/video_scaler.cpp
index 4401146927b7aca7f95ba67de411d2bfe36430d7..c19ae6726fc692fe7478e3c94362fc8c662c5dab 100644
--- a/daemon/src/video/video_scaler.cpp
+++ b/daemon/src/video/video_scaler.cpp
@@ -56,7 +56,7 @@ void VideoScaler::scale(const VideoFrame &input, VideoFrame &output)
                                 mode_,
                                 NULL, NULL, NULL);
     if (!ctx_) {
-        ERROR("Unable to create a scaler context");
+        SFL_ERR("Unable to create a scaler context");
         return;
     }
 
@@ -127,7 +127,7 @@ void VideoScaler::scale_and_pad(const VideoFrame &input, VideoFrame &output,
                                 mode_,
                                 NULL, NULL, NULL);
     if (!ctx_) {
-        ERROR("Unable to create a scaler context");
+        SFL_ERR("Unable to create a scaler context");
         return;
     }
 
diff --git a/daemon/src/video/video_sender.cpp b/daemon/src/video/video_sender.cpp
index 44b07d9ee050b930c28b083dc77360123c42fd4e..ee4387ab74d18f9bdfeb1a09ea9613b5a9f45ac5 100644
--- a/daemon/src/video/video_sender.cpp
+++ b/daemon/src/video/video_sender.cpp
@@ -69,7 +69,7 @@ void VideoSender::encodeAndSendVideo(VideoFrame& input_frame)
         --forceKeyFrame_;
 
     if (videoEncoder_->encode(input_frame, is_keyframe, frameNumber_++) < 0)
-        ERROR("encoding failed");
+        SFL_ERR("encoding failed");
 }
 
 void VideoSender::update(Observable<std::shared_ptr<VideoFrame> >* /*obs*/,
diff --git a/daemon/test/accounttest.cpp b/daemon/test/accounttest.cpp
index c97b4dc75475f273c44bfeb9e3829127c0a30e11..5e0875920c6c1d12b49e3490e43bf134adefb64f 100644
--- a/daemon/test/accounttest.cpp
+++ b/daemon/test/accounttest.cpp
@@ -39,7 +39,7 @@
 
 void AccountTest::TestAddRemove()
 {
-    DEBUG("-------------------- %s --------------------\n", __PRETTY_FUNCTION__);
+    SFL_DBG("-------------------- %s --------------------\n", __PRETTY_FUNCTION__);
 
     std::map<std::string, std::string> details(Manager::instance().getClient()->getConfigurationManager()->getAccountTemplate());
     details[CONFIG_ACCOUNT_TYPE] = "SIP";
diff --git a/daemon/test/audiolayertest.cpp b/daemon/test/audiolayertest.cpp
index 9a3d03aa9d39645ce1054e881bceba3ed775fb36..1e6d4d555f4cdf1d1c4f302039a151edc4dc17a1 100644
--- a/daemon/test/audiolayertest.cpp
+++ b/daemon/test/audiolayertest.cpp
@@ -73,7 +73,7 @@ void AudioLayerTest::testAudioLayerSwitch()
     bool wasAlsa = dynamic_cast<AlsaLayer*>(Manager::instance().getAudioDriver().get()) != 0;
 
     for (int i = 0; i < 2; i++) {
-        DEBUG("iter - %i", i);
+        SFL_DBG("iter - %i", i);
         if (wasAlsa)
             Manager::instance().setAudioManager(PULSEAUDIO_API_STR);
         else
diff --git a/daemon/test/historytest.cpp b/daemon/test/historytest.cpp
index 4c92bc2b7adbfde44e3591152bab2fa511950c81..39b7ef12b55f14c93d66ae6421731448c9acf8d8 100644
--- a/daemon/test/historytest.cpp
+++ b/daemon/test/historytest.cpp
@@ -39,13 +39,13 @@ namespace {
 void restore()
 {
     if (system("mv " HISTORY_SAMPLE_BAK " " HISTORY_SAMPLE) < 0)
-        ERROR("Restoration of %s failed", HISTORY_SAMPLE);
+        SFL_ERR("Restoration of %s failed", HISTORY_SAMPLE);
 }
 
 void backup()
 {
     if (system("cp " HISTORY_SAMPLE " " HISTORY_SAMPLE_BAK) < 0)
-        ERROR("Backup of %s failed", HISTORY_SAMPLE);
+        SFL_ERR("Backup of %s failed", HISTORY_SAMPLE);
 }
 }
 
@@ -61,7 +61,7 @@ void HistoryTest::setUp()
 
 void HistoryTest::test_create_path()
 {
-    DEBUG("-------------------- HistoryTest::test_set_path --------------------\n");
+    SFL_DBG("-------------------- HistoryTest::test_set_path --------------------\n");
 
     std::string path(HISTORY_SAMPLE);
     CPPUNIT_ASSERT(history_->path_ == path);
@@ -69,7 +69,7 @@ void HistoryTest::test_create_path()
 
 void HistoryTest::test_load_from_file()
 {
-    DEBUG("-------------------- HistoryTest::test_load_from_file --------------------\n");
+    SFL_DBG("-------------------- HistoryTest::test_load_from_file --------------------\n");
 
     bool res = history_->load(HISTORY_LIMIT);
     CPPUNIT_ASSERT(res);
@@ -77,7 +77,7 @@ void HistoryTest::test_load_from_file()
 
 void HistoryTest::test_load_items()
 {
-    DEBUG("-------------------- HistoryTest::test_load_items --------------------\n");
+    SFL_DBG("-------------------- HistoryTest::test_load_items --------------------\n");
     bool res = history_->load(HISTORY_LIMIT);
     CPPUNIT_ASSERT(res);
     CPPUNIT_ASSERT(history_->numberOfItems() == HISTORY_SAMPLE_SIZE);
@@ -85,13 +85,13 @@ void HistoryTest::test_load_items()
 
 void HistoryTest::test_save_to_file()
 {
-    DEBUG("-------------------- HistoryTest::test_save_to_file --------------------\n");
+    SFL_DBG("-------------------- HistoryTest::test_save_to_file --------------------\n");
     CPPUNIT_ASSERT(history_->save());
 }
 
 void HistoryTest::test_get_serialized()
 {
-    DEBUG("-------------------- HistoryTest::test_get_serialized --------------------\n");
+    SFL_DBG("-------------------- HistoryTest::test_get_serialized --------------------\n");
     bool res = history_->load(HISTORY_LIMIT);
     CPPUNIT_ASSERT(res);
     CPPUNIT_ASSERT(history_->getSerialized().size() == HISTORY_SAMPLE_SIZE);
diff --git a/daemon/test/instantmessagingtest.cpp b/daemon/test/instantmessagingtest.cpp
index 107d94efd3c73df8adb942b30e0fac4ab82900a0..d386c296d56b6ec1646f6a636340bd1b08e3ab65 100644
--- a/daemon/test/instantmessagingtest.cpp
+++ b/daemon/test/instantmessagingtest.cpp
@@ -166,7 +166,7 @@ void InstantMessagingTest::testGenerateXmlUriList()
     XML_SetElementHandler(parser, startElementCallback, endElementCallback);
 
     if (XML_Parse(parser, buffer.c_str(), buffer.size(), 1) == XML_STATUS_ERROR) {
-        ERROR("%s at line %d", XML_ErrorString(XML_GetErrorCode(parser)), XML_GetCurrentLineNumber(parser));
+        SFL_ERR("%s at line %d", XML_ErrorString(XML_GetErrorCode(parser)), XML_GetCurrentLineNumber(parser));
         CPPUNIT_ASSERT(false);
     }
 
@@ -218,7 +218,7 @@ void InstantMessagingTest::testGetTextArea()
     formatedText.append("--boundary--");
 
     std::string message(findTextMessage(formatedText));
-    DEBUG("Message %s", message.c_str());
+    SFL_DBG("Message %s", message.c_str());
 
     CPPUNIT_ASSERT(message == "Here is the text area");
 }
@@ -255,7 +255,7 @@ void InstantMessagingTest::testGetUriListArea()
     sfl::InstantMessaging::UriEntry::iterator iterAttr = entry.find(sfl::IM_XML_URI);
 
     if (iterAttr == entry.end()) {
-        ERROR("Did not find attribute");
+        SFL_ERR("Did not find attribute");
         CPPUNIT_ASSERT(false);
     }
 
diff --git a/daemon/test/main.cpp b/daemon/test/main.cpp
index 691afb1fb72f8836f4f50f0c51638dd91a9f1eb1..ef333ca561d73f737d9c2301e644839a17f0f483 100644
--- a/daemon/test/main.cpp
+++ b/daemon/test/main.cpp
@@ -44,12 +44,12 @@ namespace {
     void restore()
     {
         if (system("mv " CONFIG_SAMPLE_BAK " " CONFIG_SAMPLE) < 0)
-            ERROR("Restoration of %s failed", CONFIG_SAMPLE);
+            SFL_ERR("Restoration of %s failed", CONFIG_SAMPLE);
     }
     void backup()
     {
         if (system("cp " CONFIG_SAMPLE " " CONFIG_SAMPLE_BAK) < 0)
-            ERROR("Backup of %s failed", CONFIG_SAMPLE);
+            SFL_ERR("Backup of %s failed", CONFIG_SAMPLE);
     }
 }
 
@@ -97,13 +97,13 @@ int main(int argc, char* argv[])
             argvIndex++;
 
             setDebugMode(true);
-            INFO("Debug mode activated");
+            SFL_INFO("Debug mode activated");
 
         } else if (strcmp("--xml", argv[1]) == 0) {
             argvIndex++;
 
             xmlOutput = true;
-            INFO("Using XML output");
+            SFL_INFO("Using XML output");
         }
     }
 
@@ -124,7 +124,7 @@ int main(int argc, char* argv[])
     CPPUNIT_NS::Test *suite = CPPUNIT_NS::TestFactoryRegistry::getRegistry(testSuiteName).makeTest();
 
     if (suite->getChildTestCount() == 0) {
-        ERROR("Invalid test suite name: %s", testSuiteName.c_str());
+        SFL_ERR("Invalid test suite name: %s", testSuiteName.c_str());
         restore();
         return 1;
     }
diff --git a/daemon/test/numbercleanertest.cpp b/daemon/test/numbercleanertest.cpp
index c0f89f0bc1d148abea9f6f443339d5bef18511cc..036ed86ad72f074883159816c86da212ed2b47c9 100644
--- a/daemon/test/numbercleanertest.cpp
+++ b/daemon/test/numbercleanertest.cpp
@@ -53,76 +53,76 @@
 
 void NumberCleanerTest::test_format_1(void)
 {
-    DEBUG("-------------------- NumberCleanerTest::test_format_1 --------------------\n");
+    SFL_DBG("-------------------- NumberCleanerTest::test_format_1 --------------------\n");
     CPPUNIT_ASSERT(NumberCleaner::clean(NUMBER_TEST_1) == VALID_NUMBER);
 }
 
 void NumberCleanerTest::test_format_2(void)
 {
-    DEBUG("-------------------- NumberCleanerTest::test_format_2 --------------------\n");
+    SFL_DBG("-------------------- NumberCleanerTest::test_format_2 --------------------\n");
 
     CPPUNIT_ASSERT(NumberCleaner::clean(NUMBER_TEST_2) == VALID_NUMBER);
 }
 
 void NumberCleanerTest::test_format_3(void)
 {
-    DEBUG("-------------------- NumberCleanerTest::test_format_3 --------------------\n");
+    SFL_DBG("-------------------- NumberCleanerTest::test_format_3 --------------------\n");
 
     CPPUNIT_ASSERT(NumberCleaner::clean(NUMBER_TEST_3) == VALID_NUMBER);
 }
 
 void NumberCleanerTest::test_format_4(void)
 {
-    DEBUG("-------------------- NumberCleanerTest::test_format_4 --------------------\n");
+    SFL_DBG("-------------------- NumberCleanerTest::test_format_4 --------------------\n");
 
     CPPUNIT_ASSERT(NumberCleaner::clean(NUMBER_TEST_4) == VALID_NUMBER);
 }
 
 void NumberCleanerTest::test_format_5(void)
 {
-    DEBUG("-------------------- NumberCleanerTest::test_format_5 --------------------\n");
+    SFL_DBG("-------------------- NumberCleanerTest::test_format_5 --------------------\n");
 
     CPPUNIT_ASSERT(NumberCleaner::clean(NUMBER_TEST_5) == VALID_NUMBER);
 }
 
 void NumberCleanerTest::test_format_6(void)
 {
-    DEBUG("-------------------- NumberCleanerTest::test_format_6 --------------------\n");
+    SFL_DBG("-------------------- NumberCleanerTest::test_format_6 --------------------\n");
 
     CPPUNIT_ASSERT(NumberCleaner::clean(NUMBER_TEST_6) == VALID_NUMBER);
 }
 
 void NumberCleanerTest::test_format_7(void)
 {
-    DEBUG("-------------------- NumberCleanerTest::test_format_7 --------------------\n");
+    SFL_DBG("-------------------- NumberCleanerTest::test_format_7 --------------------\n");
 
     CPPUNIT_ASSERT(NumberCleaner::clean(NUMBER_TEST_7) == VALID_EXTENSION);
 }
 
 void NumberCleanerTest::test_format_8(void)
 {
-    DEBUG("-------------------- NumberCleanerTest::test_format_8 --------------------\n");
+    SFL_DBG("-------------------- NumberCleanerTest::test_format_8 --------------------\n");
 
     CPPUNIT_ASSERT(NumberCleaner::clean(NUMBER_TEST_8) == VALID_NUMBER);
 }
 
 void NumberCleanerTest::test_format_9(void)
 {
-    DEBUG("-------------------- NumberCleanerTest::test_format_9 --------------------\n");
+    SFL_DBG("-------------------- NumberCleanerTest::test_format_9 --------------------\n");
 
     CPPUNIT_ASSERT(NumberCleaner::clean(NUMBER_TEST_9) == VALID_NUMBER);
 }
 
 void NumberCleanerTest::test_format_10(void)
 {
-    DEBUG("-------------------- NumberCleanerTest::test_format_10 --------------------\n");
+    SFL_DBG("-------------------- NumberCleanerTest::test_format_10 --------------------\n");
 
     CPPUNIT_ASSERT(NumberCleaner::clean(NUMBER_TEST_1, "9") == VALID_PREPENDED_NUMBER);
 }
 
 void NumberCleanerTest::test_format_11(void)
 {
-    DEBUG("-------------------- NumberCleanerTest::test_format_11 --------------------\n");
+    SFL_DBG("-------------------- NumberCleanerTest::test_format_11 --------------------\n");
 
     CPPUNIT_ASSERT(NumberCleaner::clean(NUMBER_TEST_10, "9") == VALID_EXTENSION);
 }
diff --git a/daemon/test/siptest.cpp b/daemon/test/siptest.cpp
index abe01882c437c7c2e0512c34620d0290d6dc7ffe..16890d563b42956f622e947685d644bc6772052f 100644
--- a/daemon/test/siptest.cpp
+++ b/daemon/test/siptest.cpp
@@ -133,7 +133,7 @@ void SIPTest::testSimpleOutgoingIpCall()
     int rc = pthread_create(&thethread, NULL, sippThread, &command);
 
     if (rc)
-        std::cout << "SIPTest: ERROR; return code from pthread_create()" << std::endl;
+        std::cout << "SIPTest: SFL_ERR; return code from pthread_create()" << std::endl;
 
     std::string testaccount("IP2IP");
     std::string testcallid("callid1234");
@@ -155,7 +155,7 @@ void SIPTest::testSimpleOutgoingIpCall()
     rc = pthread_join(thethread, NULL);
 
     if (rc)
-        std::cout << "SIPTest: ERROR; return code from pthread_join(): " << rc << std::endl;
+        std::cout << "SIPTest: SFL_ERR; return code from pthread_join(): " << rc << std::endl;
     else
         std::cout << "SIPTest: completed join with thread" << std::endl;
 }
@@ -171,7 +171,7 @@ void SIPTest::testSimpleIncomingIpCall()
     int rc = pthread_create(&thethread, NULL, sippThread, &command);
 
     if (rc)
-        std::cout << "SIPTest: ERROR; return code from pthread_create()" << std::endl;
+        std::cout << "SIPTest: SFL_ERR; return code from pthread_create()" << std::endl;
 
     // sleep a while to make sure that sipp insdtance is initialized and sflphoned received
     // the incoming invite.
@@ -189,7 +189,7 @@ void SIPTest::testSimpleIncomingIpCall()
     rc = pthread_join(thethread, NULL);
 
     if (rc)
-        std::cout << "SIPTest: ERROR; return code from pthread_join(): " << rc << std::endl;
+        std::cout << "SIPTest: SFL_ERR; return code from pthread_join(): " << rc << std::endl;
     else
         std::cout << "SIPTest: completed join with thread" << std::endl;
 }
@@ -207,13 +207,13 @@ void SIPTest::testTwoOutgoingIpCall()
     int rc = pthread_create(&firstCallThread, NULL, sippThread, &firstCallCommand);
 
     if (rc)
-        std::cout << "SIPTest: ERROR; return code from pthread_create()" << std::endl;
+        std::cout << "SIPTest: SFL_ERR; return code from pthread_create()" << std::endl;
 
     pthread_t secondCallThread;
     rc = pthread_create(&secondCallThread, NULL, sippThread, &secondCallCommand);
 
     if (rc)
-        std::cout << "SIPTest: ERROR; return code from pthread_create()" << std::endl;
+        std::cout << "SIPTest: SFL_ERR; return code from pthread_create()" << std::endl;
 
     sleep(1);
 
@@ -243,7 +243,7 @@ void SIPTest::testTwoOutgoingIpCall()
     rc = pthread_join(firstCallThread, NULL);
 
     if (rc)
-        std::cout << "SIPTest: ERROR; return code from pthread_join(): " << rc << std::endl;
+        std::cout << "SIPTest: SFL_ERR; return code from pthread_join(): " << rc << std::endl;
 
     std::cout << "SIPTest: completed join with thread" << std::endl;
 
@@ -252,7 +252,7 @@ void SIPTest::testTwoOutgoingIpCall()
     rc = pthread_join(secondCallThread, NULL);
 
     if (rc)
-        std::cout << "SIPTest: ERROR; return code from pthread_join(): " << rc << std::endl;
+        std::cout << "SIPTest: SFL_ERR; return code from pthread_join(): " << rc << std::endl;
     else
         std::cout << "SIPTest: completed join with thread" << std::endl;
 }
@@ -276,7 +276,7 @@ void SIPTest::testTwoIncomingIpCall()
     int rc = pthread_create(&firstCallThread, &attr, sippThreadWithCount, &firstCallCommand);
 
     if (rc)
-        std::cout << "SIPTest: ERROR; return code from pthread_create()" << std::endl;
+        std::cout << "SIPTest: SFL_ERR; return code from pthread_create()" << std::endl;
 
     // sleep a while to make sure that sipp insdtance is initialized and sflphoned received
     // the incoming invite.
@@ -331,7 +331,7 @@ void SIPTest::testHoldIpCall()
     int rc = pthread_create(&callThread, NULL, sippThread, (void *)(&callCommand));
 
     if (rc)
-        std::cout << "SIPTest: ERROR; return code from pthread_create(): " << rc << std::endl;
+        std::cout << "SIPTest: SFL_ERR; return code from pthread_create(): " << rc << std::endl;
     else
         std::cout << "SIPTest: completed thread creation" << std::endl;
 
@@ -401,7 +401,7 @@ void SIPTest::testIncomingIpCallSdp()
     int rc = pthread_create(&thethread, NULL, sippThread, (void *)(&command));
 
     if (rc)
-        std::cout << "SIPTest: ERROR; return code from pthread_create()" << std::endl;
+        std::cout << "SIPTest: SFL_ERR; return code from pthread_create()" << std::endl;
 
     // sleep a while to make sure that sipp insdtance is initialized and sflphoned received
     // the incoming invite.
@@ -423,7 +423,7 @@ void SIPTest::testIncomingIpCallSdp()
     rc = pthread_join(thethread, NULL);
 
     if (rc)
-        std::cout << "SIPTest: ERROR; return code from pthread_join(): " << rc << std::endl;
+        std::cout << "SIPTest: SFL_ERR; return code from pthread_join(): " << rc << std::endl;
     else
         std::cout << "SIPTest: completed join with thread" << std::endl;
 }
diff --git a/daemon/test/test_utils.h b/daemon/test/test_utils.h
index 205031e56836f13721824c930a742a63d3604665..b674b51e1dd19f697f769d07215c0613c61b7222 100644
--- a/daemon/test/test_utils.h
+++ b/daemon/test/test_utils.h
@@ -33,6 +33,6 @@
 
 #include "logger.h"
 
-#define TITLE() DEBUG("Starting test..."); fflush(stderr)
+#define TITLE() SFL_DBG("Starting test..."); fflush(stderr)
 
 #endif // TEST_UTILS_H_
diff --git a/daemon/tools/dhtnode.cpp b/daemon/tools/dhtnode.cpp
index 636d6e6f0ceb7fe56f7eb0a00571bd5a08744e5a..14eb8f4c741abb4315cb5a76f61abeccc5ec6f7f 100644
--- a/daemon/tools/dhtnode.cpp
+++ b/daemon/tools/dhtnode.cpp
@@ -50,14 +50,14 @@ main(int argc, char **argv)
     setConsoleLog(true);
 
     if (argc < 2) {
-        ERROR("Entrez un port");
+        SFL_ERR("Entrez un port");
         std::terminate();
     }
 
     int i = 1;
     int p = atoi(argv[i++]);
     if (p <= 0 || p >= 0x10000) {
-        ERROR("Port invalide : %d", p);
+        SFL_ERR("Port invalide : %d", p);
         std::terminate();
     }
     in_port_t port = p;
@@ -75,7 +75,7 @@ main(int argc, char **argv)
             hints.ai_family = 0;*/
         int rc = getaddrinfo(argv[i], argv[i + 1], &hints, &info);
         if(rc != 0) {
-            ERROR("getaddrinfo: %s", gai_strerror(rc));
+            SFL_ERR("getaddrinfo: %s", gai_strerror(rc));
             std::terminate();
         }