boost logger
This commit is contained in:
parent
001d795b73
commit
b3acf81398
|
@ -5,3 +5,4 @@ CMakeDoxygenDefaults.cmake
|
|||
Makefile
|
||||
cmake_install.cmake
|
||||
bin/loader/loader
|
||||
lib/glfw
|
||||
|
|
|
@ -30,7 +30,7 @@ source_group("sources" FILES ${PROJECT_SOURCES})
|
|||
source_group("vendors" FILES ${VENDORS_SOURCES})
|
||||
|
||||
find_package(Boost 1.56 REQUIRED COMPONENTS
|
||||
program_options)
|
||||
program_options log)
|
||||
|
||||
set(EXE_1_NAME loader)
|
||||
file(
|
||||
|
@ -41,7 +41,7 @@ set(CMAKE_BINARY_DIR "bin")
|
|||
|
||||
add_executable(${EXE_1_NAME} ${EXE_1_SOURCES} ${PROJECT_HEADERS}
|
||||
${PROJECT_SHADERS} ${VENDORS_SOURCES})
|
||||
target_link_libraries(${EXE_1_NAME} glfw Boost::program_options)
|
||||
target_link_libraries(${EXE_1_NAME} glfw Boost::program_options Boost::log)
|
||||
target_include_directories(${EXE_1_NAME} PRIVATE include)
|
||||
set_target_properties(${EXE_1_NAME} PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${EXE_1_NAME})
|
||||
|
|
29
src/main.cpp
29
src/main.cpp
|
@ -1,4 +1,3 @@
|
|||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
|
@ -33,16 +32,22 @@ int main(int argc, char **argv) {
|
|||
return 1;
|
||||
}
|
||||
} catch (po::error &e) {
|
||||
cout << e.what() << endl << endl;
|
||||
BOOST_LOG_TRIVIAL(fatal) << e.what() << endl << endl;
|
||||
help(argv[0], desc);
|
||||
return EXIT_USAGE;
|
||||
}
|
||||
|
||||
/* setup the shader program */
|
||||
// set boost log level to trace on verbose
|
||||
// TODO: -v should decrease the default log level by 1 but be repeatable.
|
||||
// (default should be info)
|
||||
if (vm.count("verbose")) {
|
||||
// TODO: make verbose flag somehow global?
|
||||
printf("Reading shader files\n");
|
||||
boost::log::core::get()->set_filter(boost::log::trivial::severity >=
|
||||
boost::log::trivial::trace);
|
||||
BOOST_LOG_TRIVIAL(trace) << "verbose flag found, setting log level to trace";
|
||||
}
|
||||
|
||||
/* setup the shader program */
|
||||
BOOST_LOG_TRIVIAL(trace) << "Reading shader files";
|
||||
ifstream vertexFileStream(vm["vert"].as<string>());
|
||||
ifstream fragFileStream(vm["frag"].as<string>());
|
||||
std::stringstream vertexSource;
|
||||
|
@ -51,28 +56,26 @@ int main(int argc, char **argv) {
|
|||
fragSource << fragFileStream.rdbuf();
|
||||
|
||||
if (vertexFileStream.fail()) {
|
||||
cout << "Error while reading the vertex shader file." << endl;
|
||||
BOOST_LOG_TRIVIAL(fatal)
|
||||
<< "Error while reading the vertex shader file.";
|
||||
return EXIT_IO;
|
||||
}
|
||||
if (fragFileStream.fail()) {
|
||||
cout << "Error while reading the frag shader file." << endl;
|
||||
BOOST_LOG_TRIVIAL(fatal)
|
||||
<< "Error while reading the frag shader file.";
|
||||
return EXIT_IO;
|
||||
}
|
||||
vertexFileStream.close();
|
||||
fragFileStream.close();
|
||||
|
||||
if (vm.count("verbose")) {
|
||||
printf("Creating ShaderProgram\n");
|
||||
}
|
||||
BOOST_LOG_TRIVIAL(trace) << "Creating ShaderProgram";
|
||||
|
||||
// TODO: determinde ShaderProgram::Base with a CLI arg
|
||||
ShaderProgram shaderProgram(ShaderProgram::Base::Empty, vertexSource.str(),
|
||||
fragSource.str());
|
||||
|
||||
/* Run our main program */
|
||||
if (vm.count("verbose")) {
|
||||
printf("Starting mainWindow\n");
|
||||
}
|
||||
BOOST_LOG_TRIVIAL(trace) << "Starting mainWindow";
|
||||
int result = mainWindow(&shaderProgram);
|
||||
|
||||
return result;
|
||||
|
|
|
@ -4,6 +4,9 @@
|
|||
#include <boost/program_options/parsers.hpp>
|
||||
#include <boost/program_options/positional_options.hpp>
|
||||
#include <boost/program_options/variables_map.hpp>
|
||||
#include <boost/log/core.hpp>
|
||||
#include <boost/log/trivial.hpp>
|
||||
#include <boost/log/expressions.hpp>
|
||||
|
||||
#include "graphics.hpp"
|
||||
|
||||
|
|
Loading…
Reference in New Issue