g13gui/g13d/g13_log.cc
June Tate-Gans 04cb5d9c12 build: Start migration to cmake
This preps us for proper system installs to distributions, finding depending
libraries, and allowing us to build the foundation for the GUI and support
tooling next.

The plan is to run g13d as a system daemon managed by systemd. We'll use the
system-wide input group to control access to the daemon.

  - Add a CMakeLists for etc so we can install the udev rules.
  - Move the src dir to g13d to disambiguate a bit.
  - Update the toplevel Makefile so we can still build the old way (for now).
2021-04-25 01:19:06 -05:00

49 lines
1.2 KiB
C++

#include "g13.h"
#include <fstream>
#include <boost/log/sources/severity_feature.hpp>
#include <boost/log/sources/severity_logger.hpp>
#include <boost/log/core/core.hpp>
#include <boost/log/attributes.hpp>
#include <boost/log/trivial.hpp>
#include <boost/log/expressions.hpp>
#include <boost/log/utility/setup.hpp>
#include <boost/log/utility/setup/console.hpp>
#include <boost/log/expressions/formatters/stream.hpp>
#include <boost/log/support/date_time.hpp>
using namespace std;
namespace G13 {
void G13_Manager::set_log_level( ::boost::log::trivial::severity_level lvl ) {
boost::log::core::get()->set_filter
(
::boost::log::trivial::severity >= lvl
);
G13_OUT( "set log level to " << lvl );
}
void G13_Manager::set_log_level( const std::string &level ) {
#define CHECK_LEVEL( L ) \
if( level == BOOST_PP_STRINGIZE(L) ) { \
set_log_level( ::boost::log::trivial::L ); \
return; \
} \
CHECK_LEVEL( trace );
CHECK_LEVEL( debug );
CHECK_LEVEL( info );
CHECK_LEVEL( warning );
CHECK_LEVEL( error );
CHECK_LEVEL( fatal );
G13_LOG( error, "unknown log level" << level );
}
} // namespace G13