mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-02-18 15:23:57 +08:00
Qt logging through cloudlog (#21452)
* Qt logging through cloudlog
* sort imports
* rename to swaLogMessageHandler
* move to util
* info is high enough
* smaller diff
old-commit-hash: 54b6a9f121
This commit is contained in:
@@ -319,7 +319,8 @@ qt_flags = [
|
||||
"-DQT_QUICK_LIB",
|
||||
"-DQT_QUICKWIDGETS_LIB",
|
||||
"-DQT_QML_LIB",
|
||||
"-DQT_CORE_LIB"
|
||||
"-DQT_CORE_LIB",
|
||||
"-DQT_MESSAGELOGCONTEXT",
|
||||
]
|
||||
qt_env['CXXFLAGS'] += qt_flags
|
||||
qt_env['LIBPATH'] += ['#selfdrive/ui']
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "selfdrive/ui/qt/window.h"
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
qInstallMessageHandler(swagLogMessageHandler);
|
||||
setQtSurfaceFormat();
|
||||
|
||||
if (Hardware::EON()) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "selfdrive/ui/qt/onroad.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <QDebug>
|
||||
|
||||
#include "selfdrive/common/swaglog.h"
|
||||
#include "selfdrive/common/timing.h"
|
||||
@@ -224,10 +225,10 @@ NvgWindow::~NvgWindow() {
|
||||
|
||||
void NvgWindow::initializeGL() {
|
||||
initializeOpenGLFunctions();
|
||||
std::cout << "OpenGL version: " << glGetString(GL_VERSION) << std::endl;
|
||||
std::cout << "OpenGL vendor: " << glGetString(GL_VENDOR) << std::endl;
|
||||
std::cout << "OpenGL renderer: " << glGetString(GL_RENDERER) << std::endl;
|
||||
std::cout << "OpenGL language version: " << glGetString(GL_SHADING_LANGUAGE_VERSION) << std::endl;
|
||||
qInfo() << "OpenGL version:" << QString((const char*)glGetString(GL_VERSION));
|
||||
qInfo() << "OpenGL vendor:" << QString((const char*)glGetString(GL_VENDOR));
|
||||
qInfo() << "OpenGL renderer:" << QString((const char*)glGetString(GL_RENDERER));
|
||||
qInfo() << "OpenGL language version:" << QString((const char*)glGetString(GL_SHADING_LANGUAGE_VERSION));
|
||||
|
||||
ui_nvg_init(&QUIState::ui_state);
|
||||
prev_draw_t = millis_since_boot();
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <QStyleOption>
|
||||
|
||||
#include "selfdrive/common/params.h"
|
||||
#include "selfdrive/common/swaglog.h"
|
||||
|
||||
QString getBrand() {
|
||||
return Params().getBool("Passive") ? "dashcam" : "openpilot";
|
||||
@@ -79,3 +80,22 @@ void ClickableWidget::paintEvent(QPaintEvent *) {
|
||||
QPainter p(this);
|
||||
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
|
||||
}
|
||||
|
||||
|
||||
void swagLogMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg) {
|
||||
static std::map<QtMsgType, int> levels = {
|
||||
{QtMsgType::QtDebugMsg, 10},
|
||||
{QtMsgType::QtInfoMsg, 20},
|
||||
{QtMsgType::QtWarningMsg, 30},
|
||||
{QtMsgType::QtCriticalMsg, 40},
|
||||
{QtMsgType::QtSystemMsg, 40},
|
||||
{QtMsgType::QtFatalMsg, 50},
|
||||
};
|
||||
|
||||
std::string file, function;
|
||||
if (context.file != nullptr) file = context.file;
|
||||
if (context.function != nullptr) function = context.function;
|
||||
|
||||
auto bts = msg.toUtf8();
|
||||
cloudlog_e(levels[type], file.c_str(), context.line, function.c_str(), "%s", bts.constData());
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ void configFont(QPainter &p, const QString &family, int size, const QString &sty
|
||||
void clearLayout(QLayout* layout);
|
||||
void setQtSurfaceFormat();
|
||||
QString timeAgo(const QDateTime &date);
|
||||
void swagLogMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg);
|
||||
|
||||
class ClickableWidget : public QWidget
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user