Add RawReport log level
This commit is contained in:
parent
c04408c2dd
commit
b05e525bbc
|
@ -2,6 +2,7 @@
|
||||||
#include "../Error.h"
|
#include "../Error.h"
|
||||||
#include "../hidpp/defs.h"
|
#include "../hidpp/defs.h"
|
||||||
#include "../dj/defs.h"
|
#include "../dj/defs.h"
|
||||||
|
#include "../../util.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <system_error>
|
#include <system_error>
|
||||||
|
@ -193,6 +194,13 @@ int RawDevice::_sendReport(const std::vector<uint8_t>& report)
|
||||||
if(ret == -1)
|
if(ret == -1)
|
||||||
throw std::system_error(errno, std::system_category(), "_sendReport write failed");
|
throw std::system_error(errno, std::system_category(), "_sendReport write failed");
|
||||||
|
|
||||||
|
if(logid::global_verbosity == LogLevel::RAWREPORT) {
|
||||||
|
printf("[RAWREPORT] %s OUT: ", path.c_str());
|
||||||
|
for(auto &i : report)
|
||||||
|
printf("%02x ", i);
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -238,6 +246,13 @@ int RawDevice::_readReport(std::vector<uint8_t>& report, std::size_t maxDataLeng
|
||||||
if(0 == ret)
|
if(0 == ret)
|
||||||
throw backend::TimeoutError();
|
throw backend::TimeoutError();
|
||||||
|
|
||||||
|
if(logid::global_verbosity == LogLevel::RAWREPORT) {
|
||||||
|
printf("[RAWREPORT] %s IN: ", path.c_str());
|
||||||
|
for(auto &i : report)
|
||||||
|
printf("%02x ", i);
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@ void logid::log_printf(LogLevel level, const char* format, ...)
|
||||||
|
|
||||||
const char* logid::level_prefix(LogLevel level)
|
const char* logid::level_prefix(LogLevel level)
|
||||||
{
|
{
|
||||||
|
if(level == RAWREPORT) return "RAWREPORT";
|
||||||
if(level == DEBUG) return "DEBUG";
|
if(level == DEBUG) return "DEBUG";
|
||||||
if(level == INFO) return "INFO" ;
|
if(level == INFO) return "INFO" ;
|
||||||
if(level == WARN) return "WARN";
|
if(level == WARN) return "WARN";
|
||||||
|
@ -120,6 +121,7 @@ LogLevel logid::stringToLogLevel(std::string s)
|
||||||
std::string original_str = s;
|
std::string original_str = s;
|
||||||
std::transform(s.begin(), s.end(), s.begin(), ::tolower);
|
std::transform(s.begin(), s.end(), s.begin(), ::tolower);
|
||||||
|
|
||||||
|
if(s == "rawreport") return RAWREPORT;
|
||||||
if(s == "debug") return DEBUG;
|
if(s == "debug") return DEBUG;
|
||||||
if(s == "info") return INFO;
|
if(s == "info") return INFO;
|
||||||
if(s == "warn" || s == "warning") return WARN;
|
if(s == "warn" || s == "warning") return WARN;
|
||||||
|
|
|
@ -7,6 +7,7 @@ namespace logid
|
||||||
{
|
{
|
||||||
enum LogLevel
|
enum LogLevel
|
||||||
{
|
{
|
||||||
|
RAWREPORT,
|
||||||
DEBUG,
|
DEBUG,
|
||||||
INFO,
|
INFO,
|
||||||
WARN,
|
WARN,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user