Exemplo n.º 1
0
int main(void)
{
	// To enable the writing into a log file, we have to set the handlers to use
	// We want to write to the stdcout _and_ a log file
	typedef Yuni::Logs::StdCout< Yuni::Logs::File<> >  MyLogHandlers;

	// Our logger
	Yuni::Logs::Logger<MyLogHandlers>  logs;

	// Creating the log file (in the current directory, read-write access required)
	logs.logfile("./sample.log");
	if (not logs.logfileIsOpened())
	{
		// An error has occured. That means the log file could not be opened for
		// writing for some reason
		// In this sample, we will continue anyway
		logs.error() << "Impossible to open the log file !";
		return EXIT_FAILURE;
	}

	logs.info() << "Log file : " << logs.logfile();

	// Hello, world !, all standard verbosity levels
	logs.checkpoint() << "Hello, " << "world !";
	logs.notice() << "Hello, " << "world !";
	logs.warning() << "Hello, " << "world !";
	logs.error() << "Hello, " << "world !";
	logs.debug() << "Hello, " << "world !";
	logs.fatal() << "Hello, " << "world !";

	return 0;
}
Exemplo n.º 2
0
int main(int argc, char** argv)
{
	// All settings
	Settings settings;

	// arguments parsing
	ParseCommandLine(argc, argv, settings);


	Parser::PEG::Grammar grammar;
	grammar.onWarning.connect(& ParseWarning);
	grammar.onError.connect(& ParseError);

	String output;

	for (uint i = 0; i != (uint) settings.filenames.size(); ++i)
	{
		const String& url = settings.filenames[i];

		if (not IO::File::Exists(url))
		{
			logs.error() << "error: \"" << url << "\" file not found";
			hasError = true;
			continue;
		}

		if (grammar.loadFromFile(url))
		{
			//std::cout << grammar << std::endl;

			output = url;
			IO::ReplaceExtension(output, ".");

			switch (settings.format)
			{
				case Settings::sfCPP:
				{
					logs.info() << "generating c++ parser from " << url;
					grammar.exportToCPP(output, settings.namespaceName);
					break;
				}
			}
		}
		else
		{
			logs.error() << "impossible to load the grammar " << url;
			hasError = true;
		}
	}

	return (not hasError) ? 0 : EXIT_FAILURE;
}