src/proto2/Logger.cc
author terom
Sat, 08 Nov 2008 21:25:56 +0000
changeset 23 8d802b573cf0
child 24 b81cb670e6b2
permissions -rw-r--r--
fixed more network code, there's actually a high probability of it working now

#include "Logger.hh"

Logger::Logger (std::ostream &stream, enum LogLevel level, const char *module) : stream(stream), level(level), module(module) {
	const char *l;

	switch (level) {
		case FATAL: l = "FATAL"; break;
		case ERROR: l = "ERROR"; break;
		case WARN: l = "WARN"; break;
		case INFO: l = "INFO"; break;
		case DEBUG: l = "DEBUG"; break;
		default: l = "???"; break;
	};

	stream << l << " [" << module << "] ";
}

Logger::~Logger (void) {
	stream << std::endl;
}

std::ostream& operator<< (std::ostream &s, CL_NetComputer &c) {
	s << "[" << c.get_address().get_address() << ":" << c.get_address().get_port() << "]";

	return s;
}

std::ostream& operator<< (std::ostream &s, CL_NetObject_Server &obj) {
	s << "%" << obj.get_obj_id();

	return s;
}

std::ostream& operator<< (std::ostream &s, CL_NetObject_Client &obj) {
	s << "%" << obj.get_obj_id();

	return s;
}