Permalink
Browse files

Use var args macros for logging

  • Loading branch information...
stbuehler committed May 23, 2012
1 parent bc9769f commit 8aedb4b19ee46a08f702ca1b1d79720031dd0b3c
View
@@ -249,7 +249,7 @@ static void inFromChild(evutil_socket_t socket, short eventType, void* vcontext)
if (amount < 1) {
if (amount == 0 || errno != EAGAIN) {
if (amount < 0) {
- Log_error1(admin->logger, "Broken pipe to admin process, errno=%d", errno);
+ Log_error(admin->logger, "Broken pipe to admin process, errno=%d", errno);
} else {
Log_error(admin->logger, "Connection to admin process closed unexpectedly");
}
View
@@ -249,7 +249,7 @@ struct AdminClient* AdminClient_new(struct sockaddr_storage* addr,
context->socket = socket(addr->ss_family, SOCK_STREAM, 0);
if (context->socket < 0) {
- Log_error1(logger, "Failed to allocate socket, errno=%d", errno);
+ Log_error(logger, "Failed to allocate socket, errno=%d", errno);
return NULL;
}
@@ -266,7 +266,7 @@ struct AdminClient* AdminClient_new(struct sockaddr_storage* addr,
if (connect(context->socket, (struct sockaddr*)addr, addrLen)) {
char printedAddr[128];
evutil_inet_ntop (AF_INET, &((struct sockaddr_in*)addr)->sin_addr, printedAddr, 128);
- Log_error3(logger, "Failed to connect to admin port at [%s:%u], errno=%d",
+ Log_error(logger, "Failed to connect to admin port at [%s:%u], errno=%d",
printedAddr, ((struct sockaddr_in*)addr)->sin_port, errno);
return NULL;
}
View
@@ -32,7 +32,7 @@ struct Context
static void showMsg(struct AdminClient_Result* res, struct Context* ctx)
{
- Log_keys1(ctx->logger, "message bytes = [%s]", res->messageBytes);
+ Log_keys(ctx->logger, "message bytes = [%s]", res->messageBytes);
#ifndef Log_KEYS
Log_critical(ctx->logger, "enable Log_LEVEL=KEYS to see message content.");
#endif
@@ -42,7 +42,7 @@ static void rpcCall(String* function, Dict* args, struct Context* ctx, struct Al
{
struct AdminClient_Result* res = AdminClient_rpcCall(function, args, ctx->client, alloc);
if (res->err) {
- Log_critical2(ctx->logger,
+ Log_critical(ctx->logger,
"Failed to make function call [%s], error: [%s]",
AdminClient_errorString(res->err),
function->bytes);
@@ -51,7 +51,7 @@ static void rpcCall(String* function, Dict* args, struct Context* ctx, struct Al
}
String* error = Dict_getString(res->responseDict, String_CONST("error"));
if (error && !String_equals(error, String_CONST("none"))) {
- Log_critical2(ctx->logger,
+ Log_critical(ctx->logger,
"Router responses with error: [%s]\nCalling function: [%s]",
error->bytes,
function->bytes);
@@ -65,14 +65,14 @@ static void authorizedPasswords(List* list, struct Context* ctx)
uint32_t count = List_size(list);
for (uint32_t i = 0; i < count; i++) {
Dict* d = List_getDict(list, i);
- Log_info1(ctx->logger, "Checking authorized password %d.", i);
+ Log_info(ctx->logger, "Checking authorized password %d.", i);
if (!d) {
- Log_critical1(ctx->logger, "Not a dictionary type %d.", i);
+ Log_critical(ctx->logger, "Not a dictionary type %d.", i);
exit(-1);
}
String* passwd = Dict_getString(d, String_CONST("password"));
if (!passwd) {
- Log_critical1(ctx->logger, "Must specify a password %d.", i);
+ Log_critical(ctx->logger, "Must specify a password %d.", i);
exit(-1);
}
}
@@ -83,7 +83,7 @@ static void authorizedPasswords(List* list, struct Context* ctx)
for (uint32_t i = 0; i < count; i++) {
Dict* d = List_getDict(list, i);
String* passwd = Dict_getString(d, String_CONST("password"));
- Log_info1(ctx->logger, "Adding authorized password #[%d].", i);
+ Log_info(ctx->logger, "Adding authorized password #[%d].", i);
Dict args = Dict_CONST(
String_CONST("authType"), Int_OBJ(1), Dict_CONST(
@@ -104,13 +104,13 @@ static void udpInterface(Dict* config, struct Context* ctx)
while (entry != NULL) {
String* key = (String*) entry->key;
if (entry->val->type != Object_DICT) {
- Log_critical1(ctx->logger, "interfaces.UDPInterface.connectTo: entry [%s] "
+ Log_critical(ctx->logger, "interfaces.UDPInterface.connectTo: entry [%s] "
"is not a dictionary type.", key->bytes);
exit(-1);
}
Dict* value = entry->val->as.dictionary;
- Log_keys1(ctx->logger, "Attempting to connect to node [%s].", key->bytes);
+ Log_keys(ctx->logger, "Attempting to connect to node [%s].", key->bytes);
struct Allocator* perCallAlloc = ctx->alloc->child(ctx->alloc);
Dict_putString(value, String_CONST("address"), key, perCallAlloc);
View
@@ -249,7 +249,7 @@ static void inFromChild(evutil_socket_t socket, short eventType, void* vcontext)
if (amount < 1) {
if (amount == 0 || errno != EAGAIN) {
if (amount < 0) {
- Log_error1(admin->logger, "Broken pipe to admin process, errno=%d", errno);
+ Log_error(admin->logger, "Broken pipe to admin process, errno=%d", errno);
} else {
Log_error(admin->logger, "Connection to admin process closed unexpectedly");
}
View
@@ -308,7 +308,7 @@ static void reconf(struct Context* ctx, Dict* mainConf)
memset(&addr, 0, sizeof(struct sockaddr_storage));
int addrLen = sizeof(struct sockaddr_storage);
if (evutil_parse_sockaddr_port(address->bytes, (struct sockaddr*) &addr, &addrLen)) {
- Log_critical1(ctx->logger, "Unable to parse [%s] as an ip address port, "
+ Log_critical(ctx->logger, "Unable to parse [%s] as an ip address port, "
"eg: 127.0.0.1:11234", address->bytes);
exit(-1);
}
@@ -365,7 +365,7 @@ static void security(List* config, struct Log* logger, struct ExceptionHandler*
}
char* user = setUser(config);
if (user) {
- Log_info1(logger, "Changing user to [%s]\n", user);
+ Log_info(logger, "Changing user to [%s]\n", user);
Security_setUser(user, logger, eh);
}
if (nofiles) {
@@ -400,7 +400,7 @@ static void admin(Dict* mainConf, char* user, struct Log* logger, struct Context
memset(&addr, 0, sizeof(struct sockaddr_storage));
if (address) {
if (evutil_parse_sockaddr_port(address->bytes, (struct sockaddr*) &addr, &addrLen)) {
- Log_critical1(logger, "Unable to parse [%s] as an ip address port, "
+ Log_critical(logger, "Unable to parse [%s] as an ip address port, "
"eg: 127.0.0.1:11234", address->bytes);
exit(-1);
}
@@ -566,10 +566,10 @@ int main(int argc, char** argv)
// pid file
String* pidFile = Dict_getString(&config, String_CONST("pidFile"));
if (pidFile) {
- Log_info1(context.logger, "Writing pid of process to [%s].\n", pidFile->bytes);
+ Log_info(context.logger, "Writing pid of process to [%s].\n", pidFile->bytes);
FILE* pf = fopen(pidFile->bytes, "w");
if (!pf) {
- Log_critical2(context.logger,
+ Log_critical(context.logger,
"Failed to open pid file [%s] for writing, errno=%d\n",
pidFile->bytes,
errno);
@@ -604,10 +604,10 @@ int main(int argc, char** argv)
uint8_t address[53];
Base32_encode(address, 53, myAddr.key, 32);
- Log_info1(context.logger, "Your address is: %s.k\n", address);
+ Log_info(context.logger, "Your address is: %s.k\n", address);
uint8_t myIp[40];
Address_printIp(myIp, &myAddr);
- Log_info1(context.logger, "Your IPv6 address is: %s\n", myIp);
+ Log_info(context.logger, "Your IPv6 address is: %s\n", myIp);
// Security.
security(Dict_getList(&config, String_CONST("security")), context.logger, context.eHandler);
View
@@ -111,7 +111,7 @@ static inline void getSharedSecret(uint8_t outputSecret[32],
printHexKey(passwordHashHex, passwordHash);
uint8_t outputSecretHex[65] = "NULL";
printHexKey(outputSecretHex, outputSecret);
- Log_keys4(logger,
+ Log_keys(logger,
"Generated a shared secret:\n"
" myPublicKey=%s\n"
" herPublicKey=%s\n"
@@ -428,7 +428,7 @@ static uint8_t encryptHandshake(struct Message* message, struct CryptoAuth_Wrapp
Hex_encode(tempPrivateKeyHex, 65, wrapper->secret, 32);
uint8_t tempPubKeyHex[65];
Hex_encode(tempPubKeyHex, 65, header->handshake.encryptedTempKey, 32);
- Log_keys2(wrapper->context->logger, "Generating temporary keypair\n"
+ Log_keys(wrapper->context->logger, "Generating temporary keypair\n"
" myTempPrivateKey=%s\n"
" myTempPublicKey=%s\n",
tempPrivateKeyHex, tempPubKeyHex);
@@ -456,7 +456,7 @@ static uint8_t encryptHandshake(struct Message* message, struct CryptoAuth_Wrapp
#ifdef Log_KEYS
uint8_t tempKeyHex[65];
Hex_encode(tempKeyHex, 65, header->handshake.encryptedTempKey, 32);
- Log_keys1(wrapper->context->logger,
+ Log_keys(wrapper->context->logger,
"Wrapping temp public key:\n"
" %s\n",
tempKeyHex);
@@ -465,9 +465,9 @@ static uint8_t encryptHandshake(struct Message* message, struct CryptoAuth_Wrapp
uint8_t sharedSecret[32];
if (wrapper->nextNonce < 2) {
if (wrapper->nextNonce == 0) {
- Log_debug1(wrapper->context->logger, "@%p Sending hello packet\n", (void*) wrapper);
+ Log_debug(wrapper->context->logger, "@%p Sending hello packet\n", (void*) wrapper);
} else {
- Log_debug1(wrapper->context->logger, "@%p Sending repeat hello packet\n",
+ Log_debug(wrapper->context->logger, "@%p Sending repeat hello packet\n",
(void*) wrapper);
}
getSharedSecret(sharedSecret,
@@ -485,9 +485,9 @@ static uint8_t encryptHandshake(struct Message* message, struct CryptoAuth_Wrapp
#endif
} else {
if (wrapper->nextNonce == 2) {
- Log_debug1(wrapper->context->logger, "@%p Sending key packet\n", (void*) wrapper);
+ Log_debug(wrapper->context->logger, "@%p Sending key packet\n", (void*) wrapper);
} else {
- Log_debug1(wrapper->context->logger, "@%p Sending repeat key packet\n",
+ Log_debug(wrapper->context->logger, "@%p Sending repeat key packet\n",
(void*) wrapper);
}
// Handshake2 wrapper->tempKey holds her public temp key.
@@ -502,7 +502,7 @@ static uint8_t encryptHandshake(struct Message* message, struct CryptoAuth_Wrapp
#ifdef Log_KEYS
uint8_t tempKeyHex[65];
Hex_encode(tempKeyHex, 65, wrapper->tempKey, 32);
- Log_keys1(wrapper->context->logger,
+ Log_keys(wrapper->context->logger,
"Using their temp public key:\n"
" %s\n",
tempKeyHex);
@@ -521,7 +521,7 @@ static uint8_t encryptHandshake(struct Message* message, struct CryptoAuth_Wrapp
Hex_encode(nonceHex, 49, header->handshake.nonce, 24);
uint8_t cipherHex[65];
printHexKey(cipherHex, message->bytes);
- Log_keys3(wrapper->context->logger,
+ Log_keys(wrapper->context->logger,
"Encrypting message with:\n"
" nonce: %s\n"
" secret: %s\n"
@@ -590,7 +590,7 @@ static uint8_t sendMessage(struct Message* message, struct Interface* interface)
if (wrapper->nextNonce < 4) {
return encryptHandshake(message, wrapper);
} else {
- Log_debug1(wrapper->context->logger,
+ Log_debug(wrapper->context->logger,
"@%p Doing final step to send message. nonce=4\n", (void*) wrapper);
uint8_t secret[32];
getSharedSecret(secret,
@@ -632,7 +632,7 @@ static inline bool decryptMessage(struct CryptoAuth_Wrapper* wrapper,
// Decrypt with authentication and replay prevention.
int ret = decrypt(nonce, content, secret, wrapper->isInitiator, true);
if (ret) {
- Log_debug1(wrapper->context->logger,
+ Log_debug(wrapper->context->logger,
"Authenticated decryption failed returning %u\n",
ret);
return false;
@@ -647,7 +647,7 @@ static inline bool decryptMessage(struct CryptoAuth_Wrapper* wrapper,
}
int ret = callReceivedMessage(wrapper, content);
if (ret) {
- Log_debug1(wrapper->context->logger,
+ Log_debug(wrapper->context->logger,
"Call received message failed returning %u\n",
ret);
return false;
@@ -712,11 +712,11 @@ static uint8_t decryptHandshake(struct CryptoAuth_Wrapper* wrapper,
uint8_t* herPermKey = NULL;
if (nonce < 2) {
if (nonce == 0) {
- Log_debug2(wrapper->context->logger,
+ Log_debug(wrapper->context->logger,
"@%p Received a hello packet, using auth: %d\n",
(void*) wrapper, (passwordHash != NULL));
} else {
- Log_debug1(wrapper->context->logger, "@%p Received a repeat hello packet\n",
+ Log_debug(wrapper->context->logger, "@%p Received a repeat hello packet\n",
(void*) wrapper);
}
@@ -744,12 +744,12 @@ static uint8_t decryptHandshake(struct CryptoAuth_Wrapper* wrapper,
nextNonce = 2;
} else {
if (nonce == 2) {
- Log_debug1(wrapper->context->logger, "@%p Received a key packet\n", (void*) wrapper);
+ Log_debug(wrapper->context->logger, "@%p Received a key packet\n", (void*) wrapper);
} else if (nonce == 3) {
- Log_debug1(wrapper->context->logger, "@%p Received a repeat key packet\n",
+ Log_debug(wrapper->context->logger, "@%p Received a repeat key packet\n",
(void*) wrapper);
} else {
- Log_debug1(wrapper->context->logger,
+ Log_debug(wrapper->context->logger,
"Received a packet of unknown type! nonce=%u\n", nonce);
}
if (memcmp(header->handshake.publicKey, wrapper->herPerminentPubKey, 32)) {
@@ -775,7 +775,7 @@ static uint8_t decryptHandshake(struct CryptoAuth_Wrapper* wrapper,
Hex_encode(nonceHex, 49, header->handshake.nonce, 24);
uint8_t cipherHex[65];
printHexKey(cipherHex, message->bytes);
- Log_keys3(wrapper->context->logger,
+ Log_keys(wrapper->context->logger,
"Decrypting message with:\n"
" nonce: %s\n"
" secret: %s\n"
@@ -801,7 +801,7 @@ static uint8_t decryptHandshake(struct CryptoAuth_Wrapper* wrapper,
#ifdef Log_KEYS
uint8_t tempKeyHex[65];
Hex_encode(tempKeyHex, 65, wrapper->tempKey, 32);
- Log_keys1(wrapper->context->logger,
+ Log_keys(wrapper->context->logger,
"Unwrapping temp public key:\n"
" %s\n",
tempKeyHex);
@@ -852,7 +852,7 @@ static uint8_t receiveMessage(struct Message* received, struct Interface* interf
if (wrapper->nextNonce < 5) {
if (nonce > 3 && nonce != UINT32_MAX && knowHerKey(wrapper)) {
- Log_debug2(wrapper->context->logger,
+ Log_debug(wrapper->context->logger,
"@%p Trying final handshake step, nonce=%u\n", (void*) wrapper, nonce);
uint8_t secret[32];
getSharedSecret(secret,
@@ -914,7 +914,7 @@ struct CryptoAuth* CryptoAuth_new(Dict* config,
printHexKey(publicKeyHex, ca->publicKey);
uint8_t privateKeyHex[65];
printHexKey(privateKeyHex, ca->privateKey);
- Log_keys2(logger,
+ Log_keys(logger,
"Initialized CryptoAuth:\n myPrivateKey=%s\n myPublicKey=%s\n",
privateKeyHex,
publicKeyHex);
View
@@ -94,7 +94,7 @@ static void maintanenceCycle(void* vcontext)
#ifdef Log_DEBUG
uint8_t printable[40];
Address_printIp(printable, &targetAddr);
- Log_debug3(janitor->routerModule->logger,
+ Log_debug(janitor->routerModule->logger,
"Running search for %s, node count: %u total reach: %lu\n",
printable,
(unsigned int) NodeStore_size(janitor->nodeStore),
@@ -115,13 +115,13 @@ static void maintanenceCycle(void* vcontext)
for (uint32_t i = 0; i < janitor->routerModule->nodeStore->size; i++) {
nonZeroNodes += (janitor->routerModule->nodeStore->headers[i].reach > 0);
}
- Log_debug2(janitor->routerModule->logger,
+ Log_debug(janitor->routerModule->logger,
"Global Mean Response Time: %u non-zero nodes: %u\n",
(unsigned int) AverageRoller_getAverage(janitor->routerModule->gmrtRoller),
(unsigned int) nonZeroNodes);
size_t bytes = MallocAllocator_bytesAllocated(janitor->allocator);
- Log_debug1(janitor->routerModule->logger,
+ Log_debug(janitor->routerModule->logger,
"Using %u bytes of memory.\n",
(unsigned int) bytes);
#endif
View
@@ -140,7 +140,7 @@ struct Node* NodeStore_addNode(struct NodeStore* store,
if (addr->ip6.bytes[0] != 0xfc) {
uint8_t address[60];
Address_print(address, addr);
- Log_critical1(store->logger,
+ Log_critical(store->logger,
"tried to insert address %s which does not begin with 0xFC.\n",
address);
Assert_true(false);
@@ -160,7 +160,7 @@ struct Node* NodeStore_addNode(struct NodeStore* store,
Address_print(nodeAddr, &store->nodes[i].address);
uint8_t newAddr[20];
AddrTools_printPath(newAddr, addr->path);
- Log_debug2(store->logger,
+ Log_debug(store->logger,
"Found a better route to %s via %s\n",
nodeAddr,
newAddr);
@@ -182,7 +182,7 @@ struct Node* NodeStore_addNode(struct NodeStore* store,
if (oldReach != store->headers[i].reach) {
uint8_t nodeAddr[60];
Address_print(nodeAddr, addr);
- Log_debug3(store->logger,
+ Log_debug(store->logger,
"Altering reach for node %s, old reach %u, new reach %u.\n",
nodeAddr,
oldReach,
@@ -207,7 +207,7 @@ struct Node* NodeStore_addNode(struct NodeStore* store,
#ifdef Log_DEBUG
uint8_t nodeAddr[60];
Address_print(nodeAddr, addr);
- Log_debug2(store->logger,
+ Log_debug(store->logger,
"Discovered node: %s reach %" PRIu64,
nodeAddr,
reachDifference);
@@ -408,7 +408,7 @@ void NodeStore_remove(struct Node* node, struct NodeStore* store)
#ifdef Log_DEBUG
uint8_t addr[60];
Address_print(addr, &node->address);
- Log_debug1(store->logger, "Removing route to %s\n", addr);
+ Log_debug(store->logger, "Removing route to %s\n", addr);
#endif
store->size--;
Oops, something went wrong.

0 comments on commit 8aedb4b

Please sign in to comment.