summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Pointner <equinox@anytun.org>2009-02-22 16:00:00 +0000
committerChristian Pointner <equinox@anytun.org>2009-02-22 16:00:00 +0000
commitbb33710e45c6e3b4f6594b8c35c79e17c6e5466a (patch)
tree7ca1400100c4848b519698e81f21c743f8a2275b /src
parentfixed default log level @ anytun-controld (diff)
remove useless log priorities CRIT,EMERG,ALERT
Diffstat (limited to 'src')
-rw-r--r--src/anytun-config.cpp2
-rw-r--r--src/anytun-controld.cpp8
-rw-r--r--src/anytun.cpp24
-rw-r--r--src/authAlgo.cpp6
-rw-r--r--src/bsd/tunDevice.cpp4
-rw-r--r--src/cipher.cpp14
-rw-r--r--src/keyDerivation.cpp30
-rw-r--r--src/linux/tunDevice.cpp4
-rw-r--r--src/log.cpp5
-rw-r--r--src/log.h30
-rw-r--r--src/logTargets.cpp9
-rw-r--r--src/logTargets.h2
-rw-r--r--src/sysexec.hpp4
-rw-r--r--src/win32/tunDevice.cpp8
-rw-r--r--src/win32/winService.cpp6
15 files changed, 66 insertions, 90 deletions
diff --git a/src/anytun-config.cpp b/src/anytun-config.cpp
index d5dedf9..cafb753 100644
--- a/src/anytun-config.cpp
+++ b/src/anytun-config.cpp
@@ -96,7 +96,7 @@ int main(int argc, char* argv[])
}
StringList targets = gOpt.getLogTargets();
if(targets.empty()) {
- cLog.addTarget("stderr:4");
+ cLog.addTarget("stderr:2");
}
else {
StringList::const_iterator it;
diff --git a/src/anytun-controld.cpp b/src/anytun-controld.cpp
index f316099..30948c0 100644
--- a/src/anytun-controld.cpp
+++ b/src/anytun-controld.cpp
@@ -85,7 +85,7 @@ void syncListener()
catch (std::exception& e)
{
std::string addr = gOpt.getBindToAddr() == "" ? "*" : gOpt.getBindToAddr();
- cLog.msg(Log::PRIO_ERR) << "cannot bind to " << addr << ":" << gOpt.getBindToPort()
+ cLog.msg(Log::PRIO_ERROR) << "cannot bind to " << addr << ":" << gOpt.getBindToPort()
<< " (" << e.what() << ") exiting.." << std::endl;
//return false;
}
@@ -106,7 +106,7 @@ int main(int argc, char* argv[])
}
StringList targets = gOpt.getLogTargets();
if(targets.empty()) {
- cLog.addTarget("syslog:5,anytun-controld,daemon");
+ cLog.addTarget("syslog:3,anytun-controld,daemon");
}
else {
StringList::const_iterator it;
@@ -171,14 +171,14 @@ int main(int argc, char* argv[])
catch(std::runtime_error& e)
{
if(daemonized)
- cLog.msg(Log::PRIO_ERR) << "uncaught runtime error, exiting: " << e.what();
+ cLog.msg(Log::PRIO_ERROR) << "uncaught runtime error, exiting: " << e.what();
else
std::cout << "uncaught runtime error, exiting: " << e.what() << std::endl;
}
catch(std::exception& e)
{
if(daemonized)
- cLog.msg(Log::PRIO_ERR) << "uncaught exception, exiting: " << e.what();
+ cLog.msg(Log::PRIO_ERROR) << "uncaught exception, exiting: " << e.what();
else
std::cout << "uncaught exception, exiting: " << e.what() << std::endl;
}
diff --git a/src/anytun.cpp b/src/anytun.cpp
index fa1d186..87de39a 100644
--- a/src/anytun.cpp
+++ b/src/anytun.cpp
@@ -133,7 +133,7 @@ void syncListener()
catch (std::exception& e)
{
std::string addr = gOpt.getLocalSyncAddr() == "" ? "*" : gOpt.getLocalSyncAddr();
- cLog.msg(Log::PRIO_ERR) << "sync: cannot bind to " << addr << ":" << gOpt.getLocalSyncPort()
+ cLog.msg(Log::PRIO_ERROR) << "sync: cannot bind to " << addr << ":" << gOpt.getLocalSyncPort()
<< " (" << e.what() << ")" << std::endl;
}
@@ -214,15 +214,15 @@ void sender(void* p)
param->src.send(encrypted_packet.getBuf(), encrypted_packet.getLength(), conn.remote_end_);
} catch (std::exception& e) {
//TODO: do something here
- //cLog.msg(Log::PRIO_ERR) << "could not send data: " << e.what();
+ //cLog.msg(Log::PRIO_ERROR) << "could not send data: " << e.what();
}
}
}
catch(std::runtime_error& e) {
- cLog.msg(Log::PRIO_ERR) << "sender thread died due to an uncaught runtime_error: " << e.what();
+ cLog.msg(Log::PRIO_ERROR) << "sender thread died due to an uncaught runtime_error: " << e.what();
}
catch(std::exception& e) {
- cLog.msg(Log::PRIO_ERR) << "sender thread died due to an uncaught exception: " << e.what();
+ cLog.msg(Log::PRIO_ERROR) << "sender thread died due to an uncaught exception: " << e.what();
}
}
@@ -251,7 +251,7 @@ void receiver(void* p)
len = param->src.recv(encrypted_packet.getBuf(), encrypted_packet.getLength(), remote_end);
} catch (std::exception& e) {
//TODO: do something here
- //cLog.msg(Log::PRIO_ERR) << "could not recive packet "<< e.what();
+ //cLog.msg(Log::PRIO_ERROR) << "could not recive packet "<< e.what();
continue;
}
if(len < 0)
@@ -314,10 +314,10 @@ void receiver(void* p)
}
}
catch(std::runtime_error& e) {
- cLog.msg(Log::PRIO_ERR) << "receiver thread died due to an uncaught runtime_error: " << e.what();
+ cLog.msg(Log::PRIO_ERROR) << "receiver thread died due to an uncaught runtime_error: " << e.what();
}
catch(std::exception& e) {
- cLog.msg(Log::PRIO_ERR) << "receiver thread died due to an uncaught exception: " << e.what();
+ cLog.msg(Log::PRIO_ERROR) << "receiver thread died due to an uncaught exception: " << e.what();
}
}
@@ -370,12 +370,12 @@ int main(int argc, char* argv[])
StringList targets = gOpt.getLogTargets();
if(targets.empty()) {
#ifndef _MSC_VER
- cLog.addTarget("syslog:5,anytun,daemon");
+ cLog.addTarget("syslog:3,anytun,daemon");
#else
#ifdef WIN_SERVICE
- cLog.addTarget("eventlog:5,anytun");
+ cLog.addTarget("eventlog:3,anytun");
#else
- cLog.addTarget("stdout:5");
+ cLog.addTarget("stdout:3");
#endif
#endif
}
@@ -545,13 +545,13 @@ int main(int argc, char* argv[])
}
catch(std::runtime_error& e)
{
- cLog.msg(Log::PRIO_ERR) << "uncaught runtime error, exiting: " << e.what();
+ cLog.msg(Log::PRIO_ERROR) << "uncaught runtime error, exiting: " << e.what();
if(!daemonized)
std::cout << "uncaught runtime error, exiting: " << e.what() << std::endl;
}
catch(std::exception& e)
{
- cLog.msg(Log::PRIO_ERR) << "uncaught exception, exiting: " << e.what();
+ cLog.msg(Log::PRIO_ERROR) << "uncaught exception, exiting: " << e.what();
if(!daemonized)
std::cout << "uncaught exception, exiting: " << e.what() << std::endl;
}
diff --git a/src/authAlgo.cpp b/src/authAlgo.cpp
index 2d4e157..3f63c86 100644
--- a/src/authAlgo.cpp
+++ b/src/authAlgo.cpp
@@ -56,7 +56,7 @@ Sha1AuthAlgo::Sha1AuthAlgo(kd_dir_t d) : AuthAlgo(d), key_(DIGEST_LENGTH)
#ifndef USE_SSL_CRYPTO
gcry_error_t err = gcry_md_open(&handle_, GCRY_MD_SHA1, GCRY_MD_FLAG_HMAC);
if(err) {
- cLog.msg(Log::PRIO_CRIT) << "Sha1AuthAlgo::Sha1AuthAlgo: Failed to open message digest algo";
+ cLog.msg(Log::PRIO_ERROR) << "Sha1AuthAlgo::Sha1AuthAlgo: Failed to open message digest algo";
return;
}
#else
@@ -90,7 +90,7 @@ void Sha1AuthAlgo::generate(KeyDerivation& kd, EncryptedPacket& packet)
#ifndef USE_SSL_CRYPTO
gcry_error_t err = gcry_md_setkey(handle_, key_.getBuf(), key_.getLength());
if(err) {
- cLog.msg(Log::PRIO_ERR) << "Sha1AuthAlgo::setKey: Failed to set hmac key: " << AnytunGpgError(err);
+ cLog.msg(Log::PRIO_ERROR) << "Sha1AuthAlgo::setKey: Failed to set hmac key: " << AnytunGpgError(err);
return;
}
@@ -130,7 +130,7 @@ bool Sha1AuthAlgo::checkTag(KeyDerivation& kd, EncryptedPacket& packet)
#ifndef USE_SSL_CRYPTO
gcry_error_t err = gcry_md_setkey(handle_, key_.getBuf(), key_.getLength());
if(err) {
- cLog.msg(Log::PRIO_ERR) << "Sha1AuthAlgo::setKey: Failed to set hmac key: " << AnytunGpgError(err);
+ cLog.msg(Log::PRIO_ERROR) << "Sha1AuthAlgo::setKey: Failed to set hmac key: " << AnytunGpgError(err);
return false;
}
diff --git a/src/bsd/tunDevice.cpp b/src/bsd/tunDevice.cpp
index 5d2b152..3494458 100644
--- a/src/bsd/tunDevice.cpp
+++ b/src/bsd/tunDevice.cpp
@@ -254,14 +254,14 @@ void TunDevice::do_ifconfig()
int result = system(command.str().c_str());
if(result == -1)
- cLog.msg(Log::PRIO_ERR) << "Execution of ifconfig failed" << AnytunErrno(errno);
+ cLog.msg(Log::PRIO_ERROR) << "Execution of ifconfig failed" << AnytunErrno(errno);
else {
if(WIFEXITED(result))
cLog.msg(Log::PRIO_NOTICE) << "ifconfig returned " << WEXITSTATUS(result);
else if(WIFSIGNALED(result))
cLog.msg(Log::PRIO_NOTICE) << "ifconfig terminated after signal " << WTERMSIG(result);
else
- cLog.msg(Log::PRIO_ERR) << "Execution of ifconfig: unkown error";
+ cLog.msg(Log::PRIO_ERROR) << "Execution of ifconfig: unkown error";
}
}
diff --git a/src/cipher.cpp b/src/cipher.cpp
index 52dd908..3524052 100644
--- a/src/cipher.cpp
+++ b/src/cipher.cpp
@@ -105,14 +105,14 @@ void AesIcmCipher::init(u_int16_t key_length)
case 192: algo = GCRY_CIPHER_AES192; break;
case 256: algo = GCRY_CIPHER_AES256; break;
default: {
- cLog.msg(Log::PRIO_CRIT) << "AesIcmCipher::AesIcmCipher: cipher key length of " << key_length << " Bits is not supported";
+ cLog.msg(Log::PRIO_ERROR) << "AesIcmCipher::AesIcmCipher: cipher key length of " << key_length << " Bits is not supported";
return;
}
}
gcry_error_t err = gcry_cipher_open(&handle_, algo, GCRY_CIPHER_MODE_CTR, 0);
if( err ) {
- cLog.msg(Log::PRIO_CRIT) << "AesIcmCipher::AesIcmCipher: Failed to open cipher" << AnytunGpgError(err);
+ cLog.msg(Log::PRIO_ERROR) << "AesIcmCipher::AesIcmCipher: Failed to open cipher" << AnytunGpgError(err);
}
#endif
}
@@ -168,13 +168,13 @@ void AesIcmCipher::calc(KeyDerivation& kd, u_int8_t* in, u_int32_t ilen, u_int8_
#ifdef USE_SSL_CRYPTO
int ret = AES_set_encrypt_key(key_.getBuf(), key_.getLength()*8, &aes_key_);
if(ret) {
- cLog.msg(Log::PRIO_ERR) << "AesIcmCipher: Failed to set cipher ssl key (code: " << ret << ")";
+ cLog.msg(Log::PRIO_ERROR) << "AesIcmCipher: Failed to set cipher ssl key (code: " << ret << ")";
return;
}
#else
gcry_error_t err = gcry_cipher_setkey(handle_, key_.getBuf(), key_.getLength());
if(err) {
- cLog.msg(Log::PRIO_ERR) << "AesIcmCipher: Failed to set cipher key: " << AnytunGpgError(err);
+ cLog.msg(Log::PRIO_ERROR) << "AesIcmCipher: Failed to set cipher key: " << AnytunGpgError(err);
return;
}
#endif
@@ -184,18 +184,18 @@ void AesIcmCipher::calc(KeyDerivation& kd, u_int8_t* in, u_int32_t ilen, u_int8_
#ifndef USE_SSL_CRYPTO
err = gcry_cipher_setctr(handle_, ctr_.buf_, CTR_LENGTH);
if(err) {
- cLog.msg(Log::PRIO_ERR) << "AesIcmCipher: Failed to set cipher CTR: " << AnytunGpgError(err);
+ cLog.msg(Log::PRIO_ERROR) << "AesIcmCipher: Failed to set cipher CTR: " << AnytunGpgError(err);
return;
}
err = gcry_cipher_encrypt(handle_, out, olen, in, ilen);
if(err) {
- cLog.msg(Log::PRIO_ERR) << "AesIcmCipher: Failed to de/encrypt packet: " << AnytunGpgError(err);
+ cLog.msg(Log::PRIO_ERROR) << "AesIcmCipher: Failed to de/encrypt packet: " << AnytunGpgError(err);
return;
}
#else
if(CTR_LENGTH != AES_BLOCK_SIZE) {
- cLog.msg(Log::PRIO_ERR) << "AesIcmCipher: Failed to set cipher CTR: size don't fits";
+ cLog.msg(Log::PRIO_ERROR) << "AesIcmCipher: Failed to set cipher CTR: size don't fits";
return;
}
unsigned int num = 0;
diff --git a/src/keyDerivation.cpp b/src/keyDerivation.cpp
index c091ee6..75c49ae 100644
--- a/src/keyDerivation.cpp
+++ b/src/keyDerivation.cpp
@@ -64,7 +64,7 @@ void KeyDerivation::calcMasterKey(std::string passphrase, u_int16_t length)
{
cLog.msg(Log::PRIO_NOTICE) << "KeyDerivation: calculating master key from passphrase";
if(!length) {
- cLog.msg(Log::PRIO_ERR) << "KeyDerivation: bad master key length";
+ cLog.msg(Log::PRIO_ERROR) << "KeyDerivation: bad master key length";
return;
}
@@ -73,7 +73,7 @@ void KeyDerivation::calcMasterKey(std::string passphrase, u_int16_t length)
#else
if(length > SHA256_DIGEST_LENGTH) {
#endif
- cLog.msg(Log::PRIO_ERR) << "KeyDerivation: master key too long for passphrase algorithm";
+ cLog.msg(Log::PRIO_ERROR) << "KeyDerivation: master key too long for passphrase algorithm";
return;
}
@@ -93,7 +93,7 @@ void KeyDerivation::calcMasterSalt(std::string passphrase, u_int16_t length)
{
cLog.msg(Log::PRIO_NOTICE) << "KeyDerivation: calculating master salt from passphrase";
if(!length) {
- cLog.msg(Log::PRIO_ERR) << "KeyDerivation: bad master salt length";
+ cLog.msg(Log::PRIO_ERROR) << "KeyDerivation: bad master salt length";
return;
}
@@ -102,7 +102,7 @@ void KeyDerivation::calcMasterSalt(std::string passphrase, u_int16_t length)
#else
if(length > SHA_DIGEST_LENGTH) {
#endif
- cLog.msg(Log::PRIO_ERR) << "KeyDerivation: master key too long for passphrase algorithm";
+ cLog.msg(Log::PRIO_ERROR) << "KeyDerivation: master key too long for passphrase algorithm";
return;
}
@@ -199,12 +199,12 @@ void AesIcmKeyDerivation::init(Buffer key, Buffer salt, std::string passphrase)
void AesIcmKeyDerivation::updateMasterKey()
{
if(master_key_.getLength()*8 != key_length_) {
- cLog.msg(Log::PRIO_CRIT) << "KeyDerivation::updateMasterKey: key lengths don't match";
+ cLog.msg(Log::PRIO_ERROR) << "KeyDerivation::updateMasterKey: key lengths don't match";
return;
}
if(master_salt_.getLength() != SALT_LENGTH) {
- cLog.msg(Log::PRIO_CRIT) << "KeyDerivation::updateMasterKey: salt lengths don't match";
+ cLog.msg(Log::PRIO_ERROR) << "KeyDerivation::updateMasterKey: salt lengths don't match";
return;
}
@@ -215,7 +215,7 @@ void AesIcmKeyDerivation::updateMasterKey()
case 192: algo = GCRY_CIPHER_AES192; break;
case 256: algo = GCRY_CIPHER_AES256; break;
default: {
- cLog.msg(Log::PRIO_CRIT) << "KeyDerivation::updateMasterKey: cipher key length of " << key_length_ << " Bits is not supported";
+ cLog.msg(Log::PRIO_ERROR) << "KeyDerivation::updateMasterKey: cipher key length of " << key_length_ << " Bits is not supported";
return;
}
}
@@ -226,13 +226,13 @@ void AesIcmKeyDerivation::updateMasterKey()
gcry_error_t err = gcry_cipher_open(&handle_[i], algo, GCRY_CIPHER_MODE_CTR, 0);
if(err) {
- cLog.msg(Log::PRIO_ERR) << "KeyDerivation::updateMasterKey: Failed to open cipher: " << AnytunGpgError(err);
+ cLog.msg(Log::PRIO_ERROR) << "KeyDerivation::updateMasterKey: Failed to open cipher: " << AnytunGpgError(err);
return;
}
err = gcry_cipher_setkey(handle_[i], master_key_.getBuf(), master_key_.getLength());
if(err) {
- cLog.msg(Log::PRIO_ERR) << "KeyDerivation::updateMasterKey: Failed to set cipher key: " << AnytunGpgError(err);
+ cLog.msg(Log::PRIO_ERROR) << "KeyDerivation::updateMasterKey: Failed to set cipher key: " << AnytunGpgError(err);
return;
}
}
@@ -240,7 +240,7 @@ void AesIcmKeyDerivation::updateMasterKey()
for(int i=0; i<2; i++) {
int ret = AES_set_encrypt_key(master_key_.getBuf(), master_key_.getLength()*8, &aes_key_[i]);
if(ret) {
- cLog.msg(Log::PRIO_ERR) << "KeyDerivation::updateMasterKey: Failed to set ssl key (code: " << ret << ")";
+ cLog.msg(Log::PRIO_ERROR) << "KeyDerivation::updateMasterKey: Failed to set ssl key (code: " << ret << ")";
return;
}
}
@@ -269,7 +269,7 @@ bool AesIcmKeyDerivation::calcCtr(kd_dir_t dir, seq_nr_t* r, satp_prf_label_t la
}
if(master_salt_.getLength() != SALT_LENGTH) {
- cLog.msg(Log::PRIO_CRIT) << "KeyDerivation::calcCtr: salt lengths don't match";
+ cLog.msg(Log::PRIO_ERROR) << "KeyDerivation::calcCtr: salt lengths don't match";
return false;
}
memcpy(ctr_[dir].salt_.buf_, master_salt_.getBuf(), SALT_LENGTH);
@@ -310,24 +310,24 @@ bool AesIcmKeyDerivation::generate(kd_dir_t dir, satp_prf_label_t label, seq_nr_
#ifndef USE_SSL_CRYPTO
gcry_error_t err = gcry_cipher_reset(handle_[dir]);
if(err) {
- cLog.msg(Log::PRIO_ERR) << "KeyDerivation::generate: Failed to reset cipher: " << AnytunGpgError(err);
+ cLog.msg(Log::PRIO_ERROR) << "KeyDerivation::generate: Failed to reset cipher: " << AnytunGpgError(err);
}
err = gcry_cipher_setctr(handle_[dir], ctr_[dir].buf_, CTR_LENGTH);
if(err) {
- cLog.msg(Log::PRIO_ERR) << "KeyDerivation::generate: Failed to set CTR: " << AnytunGpgError(err);
+ cLog.msg(Log::PRIO_ERROR) << "KeyDerivation::generate: Failed to set CTR: " << AnytunGpgError(err);
return false;
}
std::memset(key.getBuf(), 0, key.getLength());
err = gcry_cipher_encrypt(handle_[dir], key, key.getLength(), NULL, 0);
if(err) {
- cLog.msg(Log::PRIO_ERR) << "KeyDerivation::generate: Failed to generate cipher bitstream: " << AnytunGpgError(err);
+ cLog.msg(Log::PRIO_ERROR) << "KeyDerivation::generate: Failed to generate cipher bitstream: " << AnytunGpgError(err);
}
return true;
#else
if(CTR_LENGTH != AES_BLOCK_SIZE) {
- cLog.msg(Log::PRIO_ERR) << "AesIcmCipher: Failed to set cipher CTR: size don't fits";
+ cLog.msg(Log::PRIO_ERROR) << "AesIcmCipher: Failed to set cipher CTR: size don't fits";
return false;
}
unsigned int num = 0;
diff --git a/src/linux/tunDevice.cpp b/src/linux/tunDevice.cpp
index 3f8e5bf..e9056b3 100644
--- a/src/linux/tunDevice.cpp
+++ b/src/linux/tunDevice.cpp
@@ -161,13 +161,13 @@ void TunDevice::do_ifconfig()
int result = system(command.str().c_str());
if(result == -1)
- cLog.msg(Log::PRIO_ERR) << "Execution of ifconfig failed: " << AnytunErrno(errno);
+ cLog.msg(Log::PRIO_ERROR) << "Execution of ifconfig failed: " << AnytunErrno(errno);
else {
if(WIFEXITED(result))
cLog.msg(Log::PRIO_NOTICE) << "ifconfig returned " << WEXITSTATUS(result);
else if(WIFSIGNALED(result))
cLog.msg(Log::PRIO_NOTICE) << "ifconfig terminated after signal " << WTERMSIG(result);
else
- cLog.msg(Log::PRIO_ERR) << "Execution of ifconfig: unkown error";
+ cLog.msg(Log::PRIO_ERROR) << "Execution of ifconfig: unkown error";
}
}
diff --git a/src/log.cpp b/src/log.cpp
index aa2c68d..2517a94 100644
--- a/src/log.cpp
+++ b/src/log.cpp
@@ -89,10 +89,7 @@ void Log::log(std::string msg, int prio)
std::string Log::prioToString(int prio)
{
switch(prio) {
- case PRIO_EMERG: return "EMERG";
- case PRIO_ALERT: return "ALERT";
- case PRIO_CRIT: return "CRIT";
- case PRIO_ERR: return "ERR";
+ case PRIO_ERROR: return "ERROR";
case PRIO_WARNING: return "WARNING";
case PRIO_NOTICE: return "NOTICE";
case PRIO_INFO: return "INFO";
diff --git a/src/log.h b/src/log.h
index cd83e84..dcdedc4 100644
--- a/src/log.h
+++ b/src/log.h
@@ -36,11 +36,6 @@
#include <sstream>
#include "logTargets.h"
-
-#ifdef LOG_SYSLOG
-#include <syslog.h>
-#endif
-
#include "threadUtils.hpp"
class Log;
@@ -64,25 +59,12 @@ private:
class Log
{
public:
-#ifdef LOG_SYSLOG
- static const int PRIO_EMERG = LOG_EMERG;
- static const int PRIO_ALERT = LOG_ALERT;
- static const int PRIO_CRIT = LOG_CRIT;
- static const int PRIO_ERR = LOG_ERR;
- static const int PRIO_WARNING = LOG_WARNING;
- static const int PRIO_NOTICE = LOG_NOTICE;
- static const int PRIO_INFO = LOG_INFO;
- static const int PRIO_DEBUG = LOG_DEBUG;
-#else
- static const int PRIO_EMERG = 0;
- static const int PRIO_ALERT = 1;
- static const int PRIO_CRIT = 2;
- static const int PRIO_ERR = 3;
- static const int PRIO_WARNING = 4;
- static const int PRIO_NOTICE = 5;
- static const int PRIO_INFO = 6;
- static const int PRIO_DEBUG = 7;
-#endif
+ static const int PRIO_ERROR = 1;
+ static const int PRIO_WARNING = 2;
+ static const int PRIO_NOTICE = 3;
+ static const int PRIO_INFO = 4;
+ static const int PRIO_DEBUG = 5;
+
static std::string prioToString(int prio);
static Log& instance();
diff --git a/src/logTargets.cpp b/src/logTargets.cpp
index 752ba29..226dce2 100644
--- a/src/logTargets.cpp
+++ b/src/logTargets.cpp
@@ -87,7 +87,7 @@ LogTarget* LogTargetList::add(std::string conf)
if(!s.good())
throw syntax_error(conf, 0);
- int prio = 0;
+ int prio = Log::PRIO_NOTICE;
s >> prio;
if(s.fail())
throw syntax_error(conf, conf.find_first_of(':')+1);
@@ -268,7 +268,7 @@ void LogTargetSyslog::log(std::string msg, int prio)
if(!opened)
return;
- syslog(prio | facility, "%s", msg.c_str());
+ syslog(prio + 2 | facility, "%s", msg.c_str());
}
LogTargetSyslog& LogTargetSyslog::setLogName(std::string l)
@@ -423,10 +423,7 @@ LogTargetWinEventlog& LogTargetWinEventlog::setLogName(std::string l)
WORD LogTargetWinEventlog::prioToEventLogType(int prio)
{
switch(prio) {
- case Log::PRIO_EMERG: return EVENTLOG_ERROR_TYPE;
- case Log::PRIO_ALERT: return EVENTLOG_ERROR_TYPE;
- case Log::PRIO_CRIT: return EVENTLOG_ERROR_TYPE;
- case Log::PRIO_ERR: return EVENTLOG_ERROR_TYPE;
+ case Log::PRIO_ERROR: return EVENTLOG_ERROR_TYPE;
case Log::PRIO_WARNING: return EVENTLOG_WARNING_TYPE;
case Log::PRIO_NOTICE: return EVENTLOG_INFORMATION_TYPE;
case Log::PRIO_INFO: return EVENTLOG_SUCCESS;
diff --git a/src/logTargets.h b/src/logTargets.h
index a7e9b60..4590f81 100644
--- a/src/logTargets.h
+++ b/src/logTargets.h
@@ -48,7 +48,7 @@
class LogTarget
{
public:
- LogTarget();;
+ LogTarget();
LogTarget(int prio);
virtual void open() = 0;
diff --git a/src/sysexec.hpp b/src/sysexec.hpp
index 9de28ec..90bde90 100644
--- a/src/sysexec.hpp
+++ b/src/sysexec.hpp
@@ -53,7 +53,7 @@ int execScript(std::string const& script, std::string const& ifname, std::string
}
execl("/bin/sh", "/bin/sh", script.c_str(), ifname.c_str(), ifnode.c_str(), (char*)NULL);
// if execl return, an error occurred
- cLog.msg(Log::PRIO_ERR) << "error on executing script: " << AnytunErrno(errno);
+ cLog.msg(Log::PRIO_ERROR) << "error on executing script: " << AnytunErrno(errno);
return -1;
}
int status = 0;
@@ -63,7 +63,7 @@ int execScript(std::string const& script, std::string const& ifname, std::string
else if(WIFSIGNALED(status))
cLog.msg(Log::PRIO_NOTICE) << "script '" << script << "' terminated after signal " << WTERMSIG(status);
else
- cLog.msg(Log::PRIO_ERR) << "executing script: unkown error";
+ cLog.msg(Log::PRIO_ERROR) << "executing script: unkown error";
return status;
}
diff --git a/src/win32/tunDevice.cpp b/src/win32/tunDevice.cpp
index f9b9092..12f025c 100644
--- a/src/win32/tunDevice.cpp
+++ b/src/win32/tunDevice.cpp
@@ -207,12 +207,12 @@ int TunDevice::read(u_int8_t* buf, u_int32_t len)
if(err == ERROR_IO_PENDING) {
WaitForSingleObject(roverlapped_.hEvent, INFINITE);
if(!GetOverlappedResult(handle_, &roverlapped_, &lenout, FALSE)) {
- cLog.msg(Log::PRIO_ERR) << "Error while trying to get overlapped result: " << AnytunErrno(GetLastError());
+ cLog.msg(Log::PRIO_ERROR) << "Error while trying to get overlapped result: " << AnytunErrno(GetLastError());
return -1;
}
}
else {
- cLog.msg(Log::PRIO_ERR) << "Error while reading from device: " << AnytunErrno(GetLastError());
+ cLog.msg(Log::PRIO_ERROR) << "Error while reading from device: " << AnytunErrno(GetLastError());
return -1;
}
}
@@ -231,12 +231,12 @@ int TunDevice::write(u_int8_t* buf, u_int32_t len)
if(err == ERROR_IO_PENDING) {
WaitForSingleObject(woverlapped_.hEvent, INFINITE);
if(!GetOverlappedResult(handle_, &woverlapped_, &lenout, FALSE)) {
- cLog.msg(Log::PRIO_ERR) << "Error while trying to get overlapped result: " << AnytunErrno(GetLastError());
+ cLog.msg(Log::PRIO_ERROR) << "Error while trying to get overlapped result: " << AnytunErrno(GetLastError());
return -1;
}
}
else {
- cLog.msg(Log::PRIO_ERR) << "Error while writing to device: " << AnytunErrno(GetLastError());
+ cLog.msg(Log::PRIO_ERROR) << "Error while writing to device: " << AnytunErrno(GetLastError());
return -1;
}
}
diff --git a/src/win32/winService.cpp b/src/win32/winService.cpp
index fefa725..5ce3d74 100644
--- a/src/win32/winService.cpp
+++ b/src/win32/winService.cpp
@@ -147,13 +147,13 @@ int real_main(int argc, char* argv[]);
VOID WINAPI WinService::main(DWORD dwArgc, LPTSTR *lpszArgv)
{
if(gWinService.started_) {
- cLog.msg(Log::PRIO_ERR) << "Service is already running";
+ cLog.msg(Log::PRIO_ERROR) << "Service is already running";
return;
}
gWinService.status_handle_ = RegisterServiceCtrlHandlerA(SVC_NAME, WinService::ctrlHandler);
if(!gWinService.status_handle_) {
- cLog.msg(Log::PRIO_ERR) << "Error on RegisterServiceCtrlHandler: " << AnytunErrno(GetLastError());
+ cLog.msg(Log::PRIO_ERROR) << "Error on RegisterServiceCtrlHandler: " << AnytunErrno(GetLastError());
return;
}
gWinService.status_.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
@@ -163,7 +163,7 @@ VOID WINAPI WinService::main(DWORD dwArgc, LPTSTR *lpszArgv)
gWinService.stop_event_ = CreateEvent(NULL, true, false, NULL);
if(!gWinService.stop_event_) {
- cLog.msg(Log::PRIO_ERR) << "WinService Error on CreateEvent: " << AnytunErrno(GetLastError());
+ cLog.msg(Log::PRIO_ERROR) << "WinService Error on CreateEvent: " << AnytunErrno(GetLastError());
gWinService.reportStatus(SERVICE_STOPPED, -1);
return;
}