Adapts logging
This commit is contained in:
@@ -7,6 +7,7 @@
|
|||||||
#include "input/InputSocketHandlerFactory.h"
|
#include "input/InputSocketHandlerFactory.h"
|
||||||
#include "DriverFactory.h"
|
#include "DriverFactory.h"
|
||||||
#include "utility/Colors.h"
|
#include "utility/Colors.h"
|
||||||
|
#include "utility/LoggerFactory.h"
|
||||||
|
|
||||||
#include <Poco/Net/SocketAddress.h>
|
#include <Poco/Net/SocketAddress.h>
|
||||||
#include <Poco/Net/ServerSocket.h>
|
#include <Poco/Net/ServerSocket.h>
|
||||||
@@ -126,7 +127,6 @@ void FlippRServer::initialize(Application &self)
|
|||||||
//this->input_server->start();
|
//this->input_server->start();
|
||||||
logger().warning(FRED("Input server not started!"));
|
logger().warning(FRED("Input server not started!"));
|
||||||
|
|
||||||
//https://gist.github.com/NIPE-SYSTEMS/5a06428c0880ed7ff3cc4304be436e3e
|
|
||||||
ServerApplication::initialize(self);
|
ServerApplication::initialize(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -248,6 +248,11 @@ void FlippRServer::defineOptions(OptionSet& options)
|
|||||||
.repeatable(false)
|
.repeatable(false)
|
||||||
.callback(OptionCallback<FlippRServer>(this, &FlippRServer::handle_config_file))
|
.callback(OptionCallback<FlippRServer>(this, &FlippRServer::handle_config_file))
|
||||||
.argument("server-config", true));
|
.argument("server-config", true));
|
||||||
|
|
||||||
|
options.addOption(Option("debug", "d", "Switch debug messages on.")
|
||||||
|
.required(false)
|
||||||
|
.repeatable(true)
|
||||||
|
.callback(OptionCallback<FlippRServer>(this, &FlippRServer::create_debug_logger)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void FlippRServer::handle_config_file(const std::string &name, const std::string &value)
|
void FlippRServer::handle_config_file(const std::string &name, const std::string &value)
|
||||||
@@ -283,5 +288,11 @@ std::string FlippRServer::get_runtime_dir()
|
|||||||
return std::getenv("XDG_RUNTIME_DIR") ? std::string(std::getenv("XDG_RUNTIME_DIR")) + "/" : DEFAULT_RUNTIME_DIR;
|
return std::getenv("XDG_RUNTIME_DIR") ? std::string(std::getenv("XDG_RUNTIME_DIR")) + "/" : DEFAULT_RUNTIME_DIR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FlippRServer::create_debug_logger(const std::string &name, const std::string &value)
|
||||||
|
{
|
||||||
|
utility::LoggerFactory::ActivateDebugLog();
|
||||||
|
logger().information(FCYN("Activated debug logging."));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,6 +42,8 @@ private:
|
|||||||
Poco::Net::HTTPServer* build_output_server();
|
Poco::Net::HTTPServer* build_output_server();
|
||||||
Poco::Net::TCPServer* build_input_server();
|
Poco::Net::TCPServer* build_input_server();
|
||||||
|
|
||||||
|
void create_debug_logger(const std::string &name, const std::string &value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const char * DEFAULT_RUNTIME_DIR = "/tmp/";
|
const char * DEFAULT_RUNTIME_DIR = "/tmp/";
|
||||||
const char * INPUT_SOCKET_NAME = "S.flippR_driver.in";
|
const char * INPUT_SOCKET_NAME = "S.flippR_driver.in";
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ std::once_flag PinController::GPIO_LIB_INITIALIZED;
|
|||||||
|
|
||||||
PinController::PinController()
|
PinController::PinController()
|
||||||
{
|
{
|
||||||
CLOG(INFO, OUTPUT_LOGGER) << "Created PinController";
|
CLOG(DEBUG, OUTPUT_LOGGER) << "Created PinController";
|
||||||
std::call_once(GPIO_LIB_INITIALIZED, wiringPiSetup);
|
std::call_once(GPIO_LIB_INITIALIZED, wiringPiSetup);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,7 +53,7 @@ void PinController::initialize_port_expander(const uint8_t i2c_address, const ui
|
|||||||
mcp23017Setup(pin_base, i2c_address);
|
mcp23017Setup(pin_base, i2c_address);
|
||||||
char hex_string[4];
|
char hex_string[4];
|
||||||
sprintf(hex_string, "%X", i2c_address);
|
sprintf(hex_string, "%X", i2c_address);
|
||||||
CLOG(INFO, OUTPUT_LOGGER) << "MCP23017 initialized with i2c-address 0x" << hex_string << " and pin-base " << int(pin_base);
|
CLOG(INFO, OUTPUT_LOGGER) << "MCP23017 initialized with i2c-address 0x" << hex_string << " and pin-base " << int(pin_base) << ".";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ namespace input
|
|||||||
Event::Event(uint8_t address, int priority, std::string name) :
|
Event::Event(uint8_t address, int priority, std::string name) :
|
||||||
address(address), priority(priority), name(name)
|
address(address), priority(priority), name(name)
|
||||||
{
|
{
|
||||||
//CLOG_IF(VLOG_IS_ON(0), INFO, INPUT_LOGGER) << "Created event: " << name << ", address: " << address;
|
CLOG_IF(VLOG_IS_ON(0), DEBUG, INPUT_LOGGER) << "Created event: " << name << ", address: " << address;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Event::getJsonString()
|
std::string Event::getJsonString()
|
||||||
|
|||||||
@@ -18,13 +18,13 @@ namespace input
|
|||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
|
|
||||||
Detector::Detector(std::unique_ptr<InputPinController> input_pin_controller, std::vector<std::shared_ptr<DistributingEvent>> events)
|
Detector::Detector(std::unique_ptr<InputPinController> input_pin_controller, std::vector<std::shared_ptr<DistributingEvent>> events) :
|
||||||
:
|
|
||||||
input_pin_controller(std::move(input_pin_controller)), events(std::move(events)), is_running(true)
|
input_pin_controller(std::move(input_pin_controller)), events(std::move(events)), is_running(true)
|
||||||
{
|
{
|
||||||
this->detect_thread = std::thread(&Detector::detect, this);
|
this->detect_thread = std::thread(&Detector::detect, this);
|
||||||
|
|
||||||
CLOG(INFO, INPUT_LOGGER) << "Created Detector and started detecting!";
|
CLOG(DEBUG, INPUT_LOGGER) << "Created Detector";
|
||||||
|
CLOG(INFO, INPUT_LOGGER) << "Detector thread running. Occuring input-events should get detected now!";
|
||||||
}
|
}
|
||||||
|
|
||||||
Detector::~Detector()
|
Detector::~Detector()
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ event_queue(queue)
|
|||||||
{
|
{
|
||||||
this->notify_thread = std::thread(&EventNotifier::notify, this);
|
this->notify_thread = std::thread(&EventNotifier::notify, this);
|
||||||
|
|
||||||
CLOG(INFO, INPUT_LOGGER) << "Created EventNotifier and started thread";
|
CLOG(DEBUG, INPUT_LOGGER) << "Created EventNotifier and started thread";
|
||||||
}
|
}
|
||||||
|
|
||||||
EventNotifier::~EventNotifier()
|
EventNotifier::~EventNotifier()
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ InputDriver::InputDriver(std::shared_ptr<EventNotifier> event_notifier, std::uni
|
|||||||
std::map<std::string, std::shared_ptr<Event>> events) :
|
std::map<std::string, std::shared_ptr<Event>> events) :
|
||||||
event_notifier(std::move(event_notifier)), detector(std::move(detector)), events(std::move(events))
|
event_notifier(std::move(event_notifier)), detector(std::move(detector)), events(std::move(events))
|
||||||
{
|
{
|
||||||
CLOG(INFO, INPUT_LOGGER) << "Created InputDriver";
|
CLOG(INFO, INPUT_LOGGER) << "InputDriver created and running.";
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputDriver::register_event_handler(std::shared_ptr<EventHandler> handler)
|
void InputDriver::register_event_handler(std::shared_ptr<EventHandler> handler)
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ std::map<std::string, std::shared_ptr<ItemType>> get_items(const std::string &co
|
|||||||
}
|
}
|
||||||
catch(json::exception & e)
|
catch(json::exception & e)
|
||||||
{
|
{
|
||||||
CLOG(INFO, OUTPUT_LOGGER) << "File " << config_path << " seems to be corrupted: " << ": " << e.what();
|
CLOG(ERROR, OUTPUT_LOGGER) << "File " << config_path << " seems to be corrupted: " << ": " << e.what();
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,13 +20,13 @@ DisplayBoardPinController::DisplayBoardPinController(std::map<std::string, uint8
|
|||||||
{
|
{
|
||||||
initialize_pins_output(0, pins_display.begin(), pins_display.end());
|
initialize_pins_output(0, pins_display.begin(), pins_display.end());
|
||||||
|
|
||||||
CLOG(INFO, OUTPUT_LOGGER) << "Created DisplayBoardPinController";
|
CLOG(DEBUG, OUTPUT_LOGGER) << "Created DisplayBoardPinController";
|
||||||
}
|
}
|
||||||
|
|
||||||
DisplayBoardPinController::DisplayBoardPinController() :
|
DisplayBoardPinController::DisplayBoardPinController() :
|
||||||
pins_display_board{}
|
pins_display_board{}
|
||||||
{
|
{
|
||||||
CLOG(INFO, OUTPUT_LOGGER) << "Created DisplayBoardPinController without pin map";
|
CLOG(DEBUG, OUTPUT_LOGGER) << "Created DisplayBoardPinController without pin map";
|
||||||
}
|
}
|
||||||
|
|
||||||
void DisplayBoardPinController::activate_displays() const
|
void DisplayBoardPinController::activate_displays() const
|
||||||
@@ -79,7 +79,6 @@ void DisplayBoardPinController::select_display_digit(uint8_t content) const
|
|||||||
void DisplayBoardPinController::run_display(uint8_t address) const
|
void DisplayBoardPinController::run_display(uint8_t address) const
|
||||||
{
|
{
|
||||||
write_pin(pins_display_board.at("display_select_" + std::to_string(address)), 0);
|
write_pin(pins_display_board.at("display_select_" + std::to_string(address)), 0);
|
||||||
|
|
||||||
write_pin(pins_display_board.at("display_select_" + std::to_string(address)), 1);
|
write_pin(pins_display_board.at("display_select_" + std::to_string(address)), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ DisplayController::DisplayController(std::map<std::string, std::shared_ptr<items
|
|||||||
this->displays.push_back(std::dynamic_pointer_cast<items::OutputDisplay>(display.second));
|
this->displays.push_back(std::dynamic_pointer_cast<items::OutputDisplay>(display.second));
|
||||||
}
|
}
|
||||||
|
|
||||||
CLOG(INFO, OUTPUT_LOGGER) << "Created DisplayController and started cycling them.";
|
CLOG(DEBUG, OUTPUT_LOGGER) << "Created DisplayController and started cycling them.";
|
||||||
|
|
||||||
activate_displays();
|
activate_displays();
|
||||||
}
|
}
|
||||||
@@ -56,13 +56,13 @@ void DisplayController::cycle_displays() const
|
|||||||
void DisplayController::activate_displays() const
|
void DisplayController::activate_displays() const
|
||||||
{
|
{
|
||||||
pin_controller->activate_displays();
|
pin_controller->activate_displays();
|
||||||
CLOG(INFO, OUTPUT_LOGGER) << "Activated all displays!";
|
CLOG(DEBUG, OUTPUT_LOGGER) << "Activated all displays!";
|
||||||
}
|
}
|
||||||
|
|
||||||
void DisplayController::deactivate_displays() const
|
void DisplayController::deactivate_displays() const
|
||||||
{
|
{
|
||||||
pin_controller->deactivate_displays();
|
pin_controller->deactivate_displays();
|
||||||
CLOG(INFO, OUTPUT_LOGGER) << "Deactivated all displays!";
|
CLOG(DEBUG, OUTPUT_LOGGER) << "Deactivated all displays!";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ namespace detail
|
|||||||
DriverBoardPinController::DriverBoardPinController(std::shared_ptr<std::mutex> output_item_mutex) :
|
DriverBoardPinController::DriverBoardPinController(std::shared_ptr<std::mutex> output_item_mutex) :
|
||||||
output_item_mutex(std::move(output_item_mutex))
|
output_item_mutex(std::move(output_item_mutex))
|
||||||
{
|
{
|
||||||
CLOG(INFO, OUTPUT_LOGGER) << "Created DriverBoardPinController.";
|
CLOG(DEBUG, OUTPUT_LOGGER) << "Created DriverBoardPinController.";
|
||||||
}
|
}
|
||||||
|
|
||||||
void DriverBoardPinController::activate(items::DriverBoardItem &driver_board_item)
|
void DriverBoardPinController::activate(items::DriverBoardItem &driver_board_item)
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ OutputDriver::OutputDriver(std::shared_ptr<output::DisplayController> display_co
|
|||||||
flippers(std::move(flippers)),
|
flippers(std::move(flippers)),
|
||||||
displays(std::move(displays))
|
displays(std::move(displays))
|
||||||
{
|
{
|
||||||
CLOG(INFO, OUTPUT_LOGGER) << "Created OutputDriver";
|
CLOG(INFO, OUTPUT_LOGGER) << "OutputDriver created and running.";
|
||||||
}
|
}
|
||||||
|
|
||||||
void OutputDriver::activate_displays() const
|
void OutputDriver::activate_displays() const
|
||||||
|
|||||||
@@ -20,14 +20,14 @@ SoundBoardPinController::SoundBoardPinController(std::shared_ptr<std::mutex> out
|
|||||||
fire_address{fire_address},
|
fire_address{fire_address},
|
||||||
address_pins{address_pins}
|
address_pins{address_pins}
|
||||||
{
|
{
|
||||||
CLOG(INFO, OUTPUT_LOGGER) << "Created SoundBoardPinController";
|
CLOG(DEBUG, OUTPUT_LOGGER) << "Created SoundBoardPinController";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SoundBoardPinController::SoundBoardPinController(std::shared_ptr<std::mutex> output_item_mutex) :
|
SoundBoardPinController::SoundBoardPinController(std::shared_ptr<std::mutex> output_item_mutex) :
|
||||||
output_item_mutex{output_item_mutex}
|
output_item_mutex{output_item_mutex}
|
||||||
{
|
{
|
||||||
CLOG(INFO, OUTPUT_LOGGER) << "Created SoundBoardPinController without addresses!";
|
CLOG(DEBUG, OUTPUT_LOGGER) << "Created SoundBoardPinController without addresses!";
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoundBoardPinController::activate(const items::detail::Sound &sound)
|
void SoundBoardPinController::activate(const items::detail::Sound &sound)
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ Display::Display(const uint8_t & address, const uint8_t & id) :
|
|||||||
address(address),
|
address(address),
|
||||||
id(id)
|
id(id)
|
||||||
{
|
{
|
||||||
// CLOG(INFO, OUTPUT_LOGGER) << "Created display with id " << id << " and address " << address << ".";
|
CLOG(DEBUG, OUTPUT_LOGGER) << "Created display with id " << int{id} << " and address " << int{address} << ".";
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t Display::get_id() const
|
uint8_t Display::get_id() const
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ public:
|
|||||||
EightDigitDisplay(uint8_t address, uint8_t id) :
|
EightDigitDisplay(uint8_t address, uint8_t id) :
|
||||||
detail::Display(address, id)
|
detail::Display(address, id)
|
||||||
{
|
{
|
||||||
CLOG(INFO, OUTPUT_LOGGER) << "Created EightDigitDisplay with address " << int{this->address} << " and id: " << int{id};
|
CLOG(DEBUG, OUTPUT_LOGGER) << "Created EightDigitDisplay with address " << int{this->address} << " and id: " << int{id};
|
||||||
}
|
}
|
||||||
|
|
||||||
~EightDigitDisplay() override = default;
|
~EightDigitDisplay() override = default;
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ namespace detail
|
|||||||
Flipper::Flipper(std::shared_ptr<DriverBoardPinController> pin_controller, const uint8_t & address, const uint8_t & pin_base, const std::string & name) :
|
Flipper::Flipper(std::shared_ptr<DriverBoardPinController> pin_controller, const uint8_t & address, const uint8_t & pin_base, const std::string & name) :
|
||||||
Item(std::move(name)), DriverBoardItem(pin_controller, address, pin_base), pin_controller(std::move(pin_controller))
|
Item(std::move(name)), DriverBoardItem(pin_controller, address, pin_base), pin_controller(std::move(pin_controller))
|
||||||
{
|
{
|
||||||
//CLOG(INFO , OUTPUT_LOGGER) << "Created flipper \"" << name << "\" with pin-base " << int(pin_base) << " and address " << int(address);
|
CLOG(DEBUG, OUTPUT_LOGGER) << "Created flipper \"" << name << "\" with pin-base " << int(pin_base) << " and address " << int(address);
|
||||||
}
|
}
|
||||||
|
|
||||||
Flipper::~Flipper()
|
Flipper::~Flipper()
|
||||||
@@ -33,13 +33,13 @@ Flipper::~Flipper()
|
|||||||
|
|
||||||
void Flipper::activate()
|
void Flipper::activate()
|
||||||
{
|
{
|
||||||
CLOG(INFO, OUTPUT_LOGGER) << "Flipper " << name << " activated";
|
CLOG(DEBUG, OUTPUT_LOGGER) << "Flipper " << name << " activated";
|
||||||
this->pin_controller->activate(*this);
|
this->pin_controller->activate(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Flipper::deactivate()
|
void Flipper::deactivate()
|
||||||
{
|
{
|
||||||
CLOG(INFO, OUTPUT_LOGGER) << "Flipper " << name << " deactivated";
|
CLOG(DEBUG, OUTPUT_LOGGER) << "Flipper " << name << " deactivated";
|
||||||
this->pin_controller->deactivate(*this);
|
this->pin_controller->deactivate(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,19 +26,19 @@ Lamp::Lamp(std::shared_ptr<DriverBoardPinController> pin_controller, const uint8
|
|||||||
activated(false),
|
activated(false),
|
||||||
activation_time(10)
|
activation_time(10)
|
||||||
{
|
{
|
||||||
//CLOG(INFO , OUTPUT_LOGGER) << "Created lamp \"" << name << "\" with pin-base " << int(pin_base) << " and address " << int(address);
|
CLOG(DEBUG, OUTPUT_LOGGER) << "Created lamp \"" << name << "\" with pin-base " << int(pin_base) << " and address " << int(address);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Lamp::activate()
|
void Lamp::activate()
|
||||||
{
|
{
|
||||||
CLOG(INFO, OUTPUT_LOGGER) << "Activate lamp " << name;
|
CLOG(DEBUG, OUTPUT_LOGGER) << "Activate lamp " << name;
|
||||||
this->activated = true;
|
this->activated = true;
|
||||||
this->pin_controller->activate(*this);
|
this->pin_controller->activate(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Lamp::deactivate()
|
void Lamp::deactivate()
|
||||||
{
|
{
|
||||||
CLOG(INFO, OUTPUT_LOGGER) << "Deactivate lamp " << name;
|
CLOG(DEBUG, OUTPUT_LOGGER) << "Deactivate lamp " << name;
|
||||||
this->activated = false;
|
this->activated = false;
|
||||||
this->pin_controller->deactivate(*this);
|
this->pin_controller->deactivate(*this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,10 @@ class SevenDigitDisplay : public virtual items::detail::Display, public virtual
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SevenDigitDisplay(uint8_t address, uint8_t id) :
|
SevenDigitDisplay(uint8_t address, uint8_t id) :
|
||||||
detail::Display(address, id) {}
|
detail::Display(address, id)
|
||||||
|
{
|
||||||
|
CLOG(DEBUG, OUTPUT_LOGGER) << "Created SevenDigitDisplay with address " << int{this->address} << " and id: " << int{id};
|
||||||
|
}
|
||||||
|
|
||||||
void write_score(unsigned int score) override
|
void write_score(unsigned int score) override
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ namespace detail
|
|||||||
Solenoid::Solenoid(std::shared_ptr<DriverBoardPinController> pin_controller, const uint8_t & address, const uint8_t & pin_base, const std::string & name, const std::chrono::milliseconds & deactivation_time)
|
Solenoid::Solenoid(std::shared_ptr<DriverBoardPinController> pin_controller, const uint8_t & address, const uint8_t & pin_base, const std::string & name, const std::chrono::milliseconds & deactivation_time)
|
||||||
: detail::Item(std::move(name)), DriverBoardItem(pin_controller, address, pin_base), pin_controller(pin_controller), deactivation_time(deactivation_time)
|
: detail::Item(std::move(name)), DriverBoardItem(pin_controller, address, pin_base), pin_controller(pin_controller), deactivation_time(deactivation_time)
|
||||||
{
|
{
|
||||||
//CLOG(INFO, OUTPUT_LOGGER) << "Created solenoid " << name << " with address " << address << " and deactivation-time: " << deactivation_time.count();
|
CLOG(DEBUG, OUTPUT_LOGGER) << "Created solenoid " << name << " with address " << int{address} << " and deactivation-time: " << deactivation_time.count();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Solenoid::triggerTask()
|
void Solenoid::triggerTask()
|
||||||
@@ -35,7 +35,7 @@ void Solenoid::triggerTask()
|
|||||||
|
|
||||||
void Solenoid::trigger()
|
void Solenoid::trigger()
|
||||||
{
|
{
|
||||||
CLOG(INFO, OUTPUT_LOGGER) << "Trigger Solenoid " << name << " for " << deactivation_time.count() << "ms";
|
CLOG(DEBUG, OUTPUT_LOGGER) << "Trigger Solenoid " << name << " for " << deactivation_time.count() << "ms";
|
||||||
this->trigger_task = std::async(std::launch::async, &Solenoid::triggerTask, this);
|
this->trigger_task = std::async(std::launch::async, &Solenoid::triggerTask, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,12 +23,12 @@ namespace detail
|
|||||||
Sound::Sound(std::shared_ptr<SoundBoardPinController> pin_controller, const uint8_t & address, const uint8_t & pin_base, const std::string & name, const std::chrono::milliseconds & deactivation_time, const u_int id)
|
Sound::Sound(std::shared_ptr<SoundBoardPinController> pin_controller, const uint8_t & address, const uint8_t & pin_base, const std::string & name, const std::chrono::milliseconds & deactivation_time, const u_int id)
|
||||||
: detail::Item(std::move(name)), DriverBoardItem(pin_controller, address, pin_base), pin_controller(std::move(pin_controller)), deactivation_time(deactivation_time), id(id)
|
: detail::Item(std::move(name)), DriverBoardItem(pin_controller, address, pin_base), pin_controller(std::move(pin_controller)), deactivation_time(deactivation_time), id(id)
|
||||||
{
|
{
|
||||||
//CLOG(INFO , OUTPUT_LOGGER) << "Created sound " << id << " \"" << name << "\" with pin-base " << int(pin_base) << " and address " << int(address) << ". Deactivation time is: " << deactivation_time.count();
|
CLOG(DEBUG, OUTPUT_LOGGER) << "Created sound " << id << " \"" << name << "\" with pin-base " << int(pin_base) << " and address " << int(address) << ". Deactivation time is: " << deactivation_time.count();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sound::play()
|
void Sound::play()
|
||||||
{
|
{
|
||||||
CLOG(INFO, OUTPUT_LOGGER) << "Play Sound " << id << " " << name;
|
CLOG(DEBUG, OUTPUT_LOGGER) << "Play Sound " << id << " " << name;
|
||||||
this->play_task = std::async(std::launch::async, &Sound::playTask, this);
|
this->play_task = std::async(std::launch::async, &Sound::playTask, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,45 +24,65 @@ void CreateInputTestLogger(el::Level level)
|
|||||||
conf.setToDefault();
|
conf.setToDefault();
|
||||||
|
|
||||||
conf.set(level, el::ConfigurationType::ToFile, "false");
|
conf.set(level, el::ConfigurationType::ToFile, "false");
|
||||||
conf.set(level, el::ConfigurationType::Format, "%datetime [%level] [%func] : %msg");
|
conf.set(level, el::ConfigurationType::Format, "%datetime [%level] [%fbase] : %msg");
|
||||||
|
|
||||||
el::Loggers::reconfigureAllLoggers(conf);
|
el::Loggers::reconfigureAllLoggers(conf);
|
||||||
}
|
}
|
||||||
|
|
||||||
el::Configurations createConfig(el::Level level)
|
el::Configurations createConfig(std::string logger)
|
||||||
{
|
{
|
||||||
el::Configurations conf;
|
el::Configurations conf;
|
||||||
conf.setToDefault();
|
conf.setToDefault();
|
||||||
|
|
||||||
conf.setGlobally(el::ConfigurationType::ToStandardOutput, "false");
|
conf.setGlobally(el::ConfigurationType::ToStandardOutput, "false");
|
||||||
|
conf.setGlobally(el::ConfigurationType::MaxLogFileSize, "1500000"); //~1.5MB
|
||||||
|
|
||||||
conf.set(level, el::ConfigurationType::ToStandardOutput, "true");
|
if (debug_log)
|
||||||
conf.set(level, el::ConfigurationType::ToFile, "true");
|
{
|
||||||
conf.set(level, el::ConfigurationType::Filename, LOGGER_FILE);
|
conf.set(el::Level::Debug, el::ConfigurationType::ToStandardOutput, "true");
|
||||||
conf.set(level, el::ConfigurationType::Format, "%datetime [%level] [%func] : %msg");
|
conf.set(el::Level::Debug, el::ConfigurationType::ToFile, "true");
|
||||||
|
conf.set(el::Level::Debug, el::ConfigurationType::Format, "%datetime [%level] [%fbase] : %msg");
|
||||||
|
conf.set(el::Level::Debug, el::ConfigurationType::Filename, LOGGER_FILE);
|
||||||
|
}
|
||||||
|
|
||||||
|
conf.set(el::Level::Info, el::ConfigurationType::ToStandardOutput, "true");
|
||||||
|
conf.set(el::Level::Info, el::ConfigurationType::ToFile, "true");
|
||||||
|
conf.set(el::Level::Info, el::ConfigurationType::Filename, LOGGER_FILE);
|
||||||
|
conf.set(el::Level::Info, el::ConfigurationType::Format, "%datetime [%level] [%fbase] : %msg");
|
||||||
|
|
||||||
|
conf.set(el::Level::Warning, el::ConfigurationType::ToStandardOutput, "true");
|
||||||
|
conf.set(el::Level::Warning, el::ConfigurationType::ToFile, "true");
|
||||||
|
conf.set(el::Level::Warning, el::ConfigurationType::Filename, LOGGER_FILE);
|
||||||
|
conf.set(el::Level::Warning, el::ConfigurationType::Format, "%datetime [%level] [%fbase] : %msg");
|
||||||
|
|
||||||
|
conf.set(el::Level::Verbose, el::ConfigurationType::ToStandardOutput, "true");
|
||||||
|
conf.set(el::Level::Verbose, el::ConfigurationType::ToFile, "true");
|
||||||
|
conf.set(el::Level::Verbose, el::ConfigurationType::Filename, LOGGER_FILE);
|
||||||
|
conf.set(el::Level::Verbose, el::ConfigurationType::Format, "%datetime [%level] [%fbase] : %msg");
|
||||||
|
|
||||||
return conf;
|
return conf;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreateInputLogger(el::Level level)
|
void CreateInputLogger()
|
||||||
{
|
{
|
||||||
el::Loggers::getLogger(INPUT_LOGGER);
|
el::Loggers::getLogger(INPUT_LOGGER);
|
||||||
|
el::Configurations conf = createConfig(INPUT_LOGGER);
|
||||||
el::Configurations conf = createConfig(level);
|
|
||||||
|
|
||||||
el::Loggers::reconfigureLogger(INPUT_LOGGER, conf);
|
el::Loggers::reconfigureLogger(INPUT_LOGGER, conf);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreateOutputLogger(el::Level level)
|
void CreateOutputLogger()
|
||||||
{
|
{
|
||||||
el::Loggers::getLogger(OUTPUT_LOGGER);
|
el::Loggers::getLogger(OUTPUT_LOGGER);
|
||||||
|
el::Configurations conf = createConfig(OUTPUT_LOGGER);
|
||||||
el::Configurations conf = createConfig(level);
|
|
||||||
|
|
||||||
el::Loggers::reconfigureLogger(OUTPUT_LOGGER, conf);
|
el::Loggers::reconfigureLogger(OUTPUT_LOGGER, conf);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
void ActivateDebugLog()
|
||||||
|
{
|
||||||
|
debug_log = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -17,11 +17,11 @@ namespace utility
|
|||||||
|
|
||||||
namespace LoggerFactory
|
namespace LoggerFactory
|
||||||
{
|
{
|
||||||
|
static bool debug_log = false;
|
||||||
void CreateInputTestLogger(el::Level level = el::Level::Global);
|
void CreateInputTestLogger(el::Level level = el::Level::Global);
|
||||||
|
void CreateInputLogger();
|
||||||
void CreateInputLogger(el::Level level = el::Level::Info);
|
void CreateOutputLogger();
|
||||||
|
void ActivateDebugLog();
|
||||||
void CreateOutputLogger(el::Level level = el::Level::Info);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user