示例#1
0
static void append_debug_meta_message(const char *message) {
	char timestamp[MAX_TIMESTAMP_LENGTH];

	format_timestamp(time(NULL), 0, timestamp, sizeof(timestamp), "-", " ", ":");

	append_debug_item(timestamp, "Meta", "", message);
}
示例#2
0
static void append_debug_pipe_message(LogPipeMessage *pipe_message) {
	char timestamp[MAX_TIMESTAMP_LENGTH];
	uint64_t seconds = pipe_message->timestamp / 1000000;
	int microseconds = pipe_message->timestamp % 1000000;
	const char *level = "Unknown";
	char source[192];

	format_timestamp(seconds, microseconds, timestamp, sizeof(timestamp),
	                 "-", " ", ":");

	switch (pipe_message->level) {
	case LOG_LEVEL_ERROR: level = "Error"; break;
	case LOG_LEVEL_WARN:  level = "Warn";  break;
	case LOG_LEVEL_INFO:  level = "Info";  break;
	case LOG_LEVEL_DEBUG: level = "Debug"; break;
	}

	if ((pipe_message->flags & LOG_PIPE_MESSAGE_FLAG_LIBUSB) != 0) {
		_snprintf(source, sizeof(source), "libusb:%s", pipe_message->source);
	} else {
		_snprintf(source, sizeof(source), "%s:%d", pipe_message->source,
		          pipe_message->line);
	}

	append_debug_item(timestamp, level, source, pipe_message->message);
}
示例#3
0
static void append_debug_pipe_message(LogPipeMessage *pipe_message) {
	char timestamp[MAX_TIMESTAMP_LEN];
	uint64_t seconds = pipe_message->timestamp / 1000000;
	int microseconds = pipe_message->timestamp % 1000000;
	const char *level = "<unknown>";
	const char *category = "<unknown>";
	char line[64];

	format_timestamp(seconds, microseconds, timestamp, sizeof(timestamp), "-", " ", ":");

	switch (pipe_message->level) {
	case LOG_LEVEL_NONE:  level = "None";  break;
	case LOG_LEVEL_ERROR: level = "Error"; break;
	case LOG_LEVEL_WARN:  level = "Warn";  break;
	case LOG_LEVEL_INFO:  level = "Info";  break;
	case LOG_LEVEL_DEBUG: level = "Debug"; break;
	}

	switch (pipe_message->category) {
	case LOG_CATEGORY_EVENT:     category = "Event";     break;
	case LOG_CATEGORY_USB:       category = "USB";       break;
	case LOG_CATEGORY_NETWORK:   category = "Network";   break;
	case LOG_CATEGORY_HOTPLUG:   category = "Hotplug";   break;
	case LOG_CATEGORY_HARDWARE:  category = "Hardware";  break;
	case LOG_CATEGORY_WEBSOCKET: category = "WebSocket"; break;
	case LOG_CATEGORY_OTHER:     category = "Other";     break;
	case LOG_CATEGORY_LIBUSB:    category = "libusb";    break;
	}

	_snprintf(line, sizeof(line), "%d", pipe_message->line);

	append_debug_item(timestamp, level, category, pipe_message->file, line,
	                  pipe_message->function, pipe_message->message);
}