Logger tweaks

Commit amended for code style and minor cleanup by Adam Honse <calcprogrammer1@gmail.com>
This commit is contained in:
k1-801 2021-03-24 02:38:30 +04:00 committed by Adam Honse
parent 0089852395
commit f1d6c2953d
6 changed files with 387 additions and 125 deletions

View file

@ -74,6 +74,7 @@ ResourceManager::~ResourceManager()
void ResourceManager::RegisterI2CBus(i2c_smbus_interface *bus)
{
LOG_NOTICE("Registering an I2C bus: %s", bus->device_name);
busses.push_back(bus);
}
@ -84,7 +85,7 @@ std::vector<i2c_smbus_interface*> & ResourceManager::GetI2CBusses()
void ResourceManager::RegisterRGBController(RGBController *rgb_controller)
{
LogAppend(LogSection("Detection", LL_DEBUG), LL_DEBUG, "Registering RGB controller: %s", rgb_controller->name.c_str());
LOG_NOTICE("Registering RGB controller: %s", rgb_controller->name.c_str());
rgb_controllers_hw.push_back(rgb_controller);
DeviceListChanged();
@ -431,14 +432,8 @@ void ResourceManager::DetectDevicesThreadFunction()
unsigned int prev_count = 0;
bool save_settings = false;
std::vector<bool> size_used;
int detection_section;
/*-------------------------------------------------*\
| Create a log debug section named Detection |
\*-------------------------------------------------*/
detection_section = LogSection("Detection", LL_DEBUG);
LogAppend(detection_section, LL_NOTICE, "Detection started" );
LOG_NOTICE("Detection started");
size_used.resize(rgb_controllers_sizes.size());
@ -493,7 +488,7 @@ void ResourceManager::DetectDevicesThreadFunction()
/*-------------------------------------------------*\
| Detect i2c busses |
\*-------------------------------------------------*/
LogAppend(detection_section, LL_DEBUG, "Detecting I2C/SMBus busses");
LOG_NOTICE("Detecting I2C/SMBus busses");
for(unsigned int i2c_bus_detector_idx = 0; i2c_bus_detector_idx < i2c_bus_detectors.size() && detection_is_required.load(); i2c_bus_detector_idx++)
{
@ -504,7 +499,7 @@ void ResourceManager::DetectDevicesThreadFunction()
/*-------------------------------------------------*\
| Detect i2c devices |
\*-------------------------------------------------*/
LogAppend(detection_section, LL_DEBUG, "Detecting I2C/SMBus devices");
LOG_NOTICE("Detecting I2C/SMBus devices");
for(unsigned int i2c_detector_idx = 0; i2c_detector_idx < i2c_device_detectors.size() && detection_is_required.load(); i2c_detector_idx++)
{
@ -582,7 +577,7 @@ void ResourceManager::DetectDevicesThreadFunction()
if(hid_safe_mode)
{
LogAppend(detection_section, LL_NOTICE, "Detecting HID devices in safe mode");
LOG_NOTICE("Detecting HID devices in safe mode");
/*-----------------------------------------------------------------------------*\
| Loop through all available detectors. If all required information matches, |
@ -592,7 +587,7 @@ void ResourceManager::DetectDevicesThreadFunction()
{
hid_devices = hid_enumerate(hid_device_detectors[hid_detector_idx].address >> 16, hid_device_detectors[hid_detector_idx].address & 0x0000FFFF);
LogAppend(detection_section, LL_NOTICE, "Trying to run detector for [%s] (for 0x%08hx)", hid_device_detectors[hid_detector_idx].name.c_str(), hid_device_detectors[hid_detector_idx].address);
LOG_VERBOSE("Trying to run detector for [%s] (for 0x%08hx)", hid_device_detectors[hid_detector_idx].name.c_str(), hid_device_detectors[hid_detector_idx].address);
current_hid_device = hid_devices;
@ -662,7 +657,7 @@ void ResourceManager::DetectDevicesThreadFunction()
}
else
{
LogAppend(detection_section, LL_NOTICE, "Detecting HID devices");
LOG_NOTICE("Detecting HID devices");
/*-------------------------------------------------*\
| Iterate through all devices in list and run |
@ -672,6 +667,8 @@ void ResourceManager::DetectDevicesThreadFunction()
while(current_hid_device)
{
LOG_DEBUG("HID device [0x%04x:$0x%04x]", current_hid_device->vendor_id, current_hid_device->product_id);
detection_string = "";
DetectionProgressChanged();
@ -700,6 +697,7 @@ void ResourceManager::DetectDevicesThreadFunction()
)
{
detection_string = hid_device_detectors[hid_detector_idx].name.c_str();
LOG_DEBUG("Detector found: %s", detection_string);
/*-------------------------------------------------*\
| Check if this detector is enabled or needs to be |
@ -713,6 +711,8 @@ void ResourceManager::DetectDevicesThreadFunction()
if(this_device_enabled)
{
LOG_DEBUG("Detector %s is enabled, running it", detection_string);
DetectionProgressChanged();
hid_device_detectors[hid_detector_idx].function(current_hid_device, hid_device_detectors[hid_detector_idx].name);
@ -744,7 +744,7 @@ void ResourceManager::DetectDevicesThreadFunction()
/*-------------------------------------------------*\
| Detect other devices |
\*-------------------------------------------------*/
LogAppend(detection_section, LL_NOTICE, "Detecting other devices");
LOG_NOTICE("Detecting other devices");
for(unsigned int detector_idx = 0; detector_idx < device_detectors.size() && detection_is_required.load(); detector_idx++)
{
@ -812,18 +812,19 @@ void ResourceManager::DetectDevicesThreadFunction()
if(save_settings)
{
LogAppend(detection_section, LL_NOTICE, "Saving detector settings");
LOG_NOTICE("Saving detector settings");
settings_manager->SetSettings("Detectors", detector_settings);
settings_manager->SaveSettings();
}
LogAppend(detection_section, LL_NOTICE, "Detection completed");
LOG_NOTICE("Detection completed");
}
void ResourceManager::StopDeviceDetection()
{
LOG_NOTICE("Detection abort requested");
detection_is_required = false;
detection_percent = 100;
detection_string = "Stopping";