static void log_create( struct nvpair_database *db, const char *key, struct nvpair *nv )
{
	log_select(db);
	log_time(db);

	fprintf(db->logfile,"C %s\n",key);
	nvpair_print_text(nv,db->logfile);
}
Example #2
0
static void log_message( struct jx_database *db, const char *fmt, ... )
{
	va_list args;
	va_start(args,fmt);

	log_select(db);
	log_time(db);
	vfprintf(db->logfile,fmt,args);

	va_end(args);
}
static void log_updates( struct nvpair_database *db, const char *key, struct nvpair *a, struct nvpair *b )
{
	log_select(db);

	char *name, *avalue, *bvalue;

	// For each item in the old nvpair:
	// If the new one is different, log an update event.
	// If the new one is missing, log a remove event.

	hash_table_firstkey(a->table);
	while(hash_table_nextkey(a->table,&name,(void**)&avalue)) {

		// Do not log these special cases, because they do not carry new information:
		if(!strcmp(name,"lastheardfrom")) continue;
		if(!strcmp(name,"uptime")) continue;

		bvalue = hash_table_lookup(b->table,name);
		if(bvalue) {
			if(!strcmp(avalue,bvalue)) {
				// items match, do nothing.
			} else { 
				log_time(db);
				fprintf(db->logfile,"U %s %s %s\n",key,name,bvalue);
			}
		} else {
       			log_time(db);
			fprintf(db->logfile,"R %s %s\n",key,name);
		}
	}

	// For each item in the new nvpair:
	// If it doesn't exist in the old one, log an update event.

	hash_table_firstkey(b->table);
	while(hash_table_nextkey(b->table,&name,(void**)&bvalue)) {
		avalue = hash_table_lookup(a->table,name);
		if(!avalue) {
       			log_time(db);
			fprintf(db->logfile,"U %s %s %s\n",key,name,bvalue);
		}
	}
} 
Example #4
0
void err_select(select_t* s)
{
	log_select(s, L_ERR);
}
Example #5
0
void print_select(select_t* s)
{
	log_select(s, L_DBG);
}
static void log_delete( struct nvpair_database *db, const char *key )
{
	log_select(db);
	log_time(db);
	fprintf(db->logfile,"D %s\n",key);
}