#include <log4cplus/logger.h>
#include <log4cplus/configurator.h>

#include "Client.h"

#include <iostream>

int main(int argc, const char **argv) {
	log4cplus::BasicConfigurator basicConfig;
	basicConfig.configure();

	log4cplus::PropertyConfigurator propConfig("logging.cfg");
	propConfig.configure();

	log4cplus::Logger logger = log4cplus::Logger::getInstance("main");
	LOG4CPLUS_INFO(logger, "starting gremlin");

	LOG4CPLUS_INFO(logger, "arguments (" << argc << "):");
	for (size_t i = 0; i < argc; i++)
		LOG4CPLUS_INFO(logger, " - " << argv[i]);

	try {
		gln::Client app;
		gln::Config config;
		config.load(argc, argv);

		app.initialize(config);
		while (app.isRunning())
			app.update();
		app.shutdown();
	} catch (const char *str) {
		std::cerr << "Exception: " << str << std::endl;
		return 1;
	} catch (const std::exception &e) {
		std::cerr << "Exception: " << e.what() << std::endl;
		return 1;
	}

	return 0;
}

