Exemplo n.º 1
0
static void log_socket(FILE *f, void *data) {
	struct socket_message *m = (struct socket_message *)data;
	if (m->type == SOCKET_DATA) {
		fprintf(f, "[socket] %d %d %d\n", m->id, m->type, m->size);
		log_blob(f, m->data, m->size);
		fprintf(f, "\n");
		fflush(f);
	}
}
Exemplo n.º 2
0
void log_output(FILE *f, struct message *m) {
	if (m->proto == SERVICE_PROTO_SOCKET) {
		log_socket(f, m->data);
	} else {
		uint32_t ti = timer_now();
		fprintf(f, "[%u] %d %d %u\n", m->source, m->proto, m->session, ti);
		log_blob(f, m->data, m->size);
		fprintf(f, "\n");
		fflush(f);
	}
}
Exemplo n.º 3
0
void 
skynet_log_output(FILE *f, uint32_t source, int type, int session, void * buffer, size_t sz) {
	if (type == PTYPE_SOCKET) {
		log_socket(f, buffer, sz);
	} else {
		uint32_t ti = skynet_gettime();
		fprintf(f, ":%08x %d %d %u ", source, type, session, ti);
		log_blob(f, buffer, sz);
		fprintf(f,"\n");
		fflush(f);
	}
}
Exemplo n.º 4
0
static void
log_socket(FILE * f, struct skynet_socket_message * message, size_t sz) {
	fprintf(f, "[socket] %d %d %d ", message->type, message->id, message->ud);

	if (message->buffer == NULL) {
		const char *buffer = (const char *)(message + 1);
		sz -= sizeof(*message);
		const char * eol = memchr(buffer, '\0', sz);
		if (eol) {
			sz = eol - buffer;
		}
		fprintf(f, "[%*s]", (int)sz, (const char *)buffer);
	} else {
		sz = message->ud;
		log_blob(f, message->buffer, sz);
	}
	fprintf(f, "\n");
	fflush(f);
}