adjust debug output

This commit is contained in:
whottgen 2005-03-01 15:53:06 +00:00
parent 8b7af6781f
commit f03172ab10

View File

@ -82,7 +82,7 @@ void htcache_insert(htcache_t *handle, const char *key, const char *value, int v
int ret;
mydata_t *mydata;
syslog(LOG_DEBUG, "cache_insert: inserting %s -> %s (size %d)", key, (char*) value, value_size);
syslog(LOG_DEBUG, "htcache_insert: inserting %s -> %s (size %d)", key, (char*) value, value_size);
dkey.dsize = strlen(key) + 1; /* one more for the terminating \0 */
dkey.dptr = (char*) key;
data.dsize = (sizeof(mydata_t) + value_size + 1);
@ -96,9 +96,9 @@ void htcache_insert(htcache_t *handle, const char *key, const char *value, int v
if (NULL != (cache = dbm_open(handle->file, O_RDWR | O_CREAT, 0644))) {
ret = dbm_store(cache, dkey, data, DBM_INSERT);
if (ret != 0) {
syslog(LOG_DEBUG, "cache_insert: couldn't insert record");
syslog(LOG_DEBUG, "htcache_insert: couldn't insert record");
} else {
syslog(LOG_DEBUG, "cache_insert: record inserted");
syslog(LOG_DEBUG, "htcache_insert: record inserted");
}
dbm_close(cache);
}
@ -106,7 +106,7 @@ void htcache_insert(htcache_t *handle, const char *key, const char *value, int v
free(mydata);
#else
syslog(LOG_DEBUG, "cache_insert: cache disabled");
syslog(LOG_DEBUG, "htcache_insert: cache disabled");
#endif /* ENABLE_CACHE */
}
@ -119,7 +119,7 @@ int htcache_lookup(htcache_t *handle, const char* key, char** value, int* value_
mydata_t *mydata;
int value_size, ret, res = -1;
syslog(LOG_DEBUG, "cache_lookup: looking up %s, expiry %d",
syslog(LOG_DEBUG, "htcache_lookup: looking up %s, expiry %d",
key, handle->expiry);
if (NULL != (cache = dbm_open(handle->file, O_RDONLY, 0644))) {
@ -127,14 +127,14 @@ int htcache_lookup(htcache_t *handle, const char* key, char** value, int* value_
dkey.dptr = (char*) key;
data = dbm_fetch(cache, dkey);
if (NULL == data.dptr) {
syslog(LOG_DEBUG, "cache_lookup: nothing found");
syslog(LOG_DEBUG, "htcache_lookup: nothing found");
dbm_close(cache);
} else {
mydata = (mydata_t *) data.dptr;
syslog(LOG_DEBUG, "cache_lookup: found: %s %d %d %s (size %d)",
syslog(LOG_DEBUG, "htcache_lookup: found: %s %d %d %s (size %d)",
key, mydata->timestamp, mydata->value_size, mydata->value, data.dsize);
if ((mydata->timestamp + handle->expiry) > time(NULL)) {
syslog(LOG_DEBUG, "cache_lookup: not yet expired");
syslog(LOG_DEBUG, "htcache_lookup: not yet expired");
value_size = mydata->value_size;
output = (char*) htmalloc(value_size+5);
memcpy(output, mydata->value, value_size);
@ -147,7 +147,7 @@ int htcache_lookup(htcache_t *handle, const char* key, char** value, int* value_
dbm_close(cache);
res = 0;
} else {
syslog(LOG_DEBUG, "cache_lookup: expired, will be deleted from cache");
syslog(LOG_DEBUG, "htcache_lookup: expired, will be deleted from cache");
/* free(data.dptr); --- Berkeley DB frees on its own */
dbm_close(cache);
@ -155,9 +155,9 @@ int htcache_lookup(htcache_t *handle, const char* key, char** value, int* value_
if (NULL != (cache = dbm_open(handle->file, O_RDWR, 0644))) {
ret = dbm_delete(cache, dkey);
if (ret != 0) {
syslog(LOG_DEBUG, "cache_insert: couldn't delete record");
syslog(LOG_DEBUG, "htcache_lookup: couldn't delete record");
} else {
syslog(LOG_DEBUG, "cache_insert: record deleted");
syslog(LOG_DEBUG, "htcache_lookup: record deleted");
}
dbm_close(cache);
res = -2;