Skip to content

Commit

Permalink
Clean up logging (#360)
Browse files Browse the repository at this point in the history
* Clean up logging

* Version bump

* Remove timezone FAQ
  • Loading branch information
Eeems authored Jun 26, 2024
1 parent da7935d commit 3c85e2f
Show file tree
Hide file tree
Showing 21 changed files with 343 additions and 394 deletions.
6 changes: 3 additions & 3 deletions applications/system-service/apibase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ int APIBase::hasPermission(QString permission, const char* sender){
if(getpgid(getpid()) == getSenderPgid()){
return true;
}
qDebug() << "Checking permission" << permission << "from" << sender;
O_INFO("Checking permission" << permission << "from" << sender);
for(auto name : appsAPI->runningApplicationsNoSecurityCheck().keys()){
auto app = appsAPI->getApplication(name);
if(app == nullptr){
continue;
}
if(app->processId() == getSenderPgid()){
auto result = app->permissions().contains(permission);
qDebug() << app->name() << result;
O_INFO(app->name() << result);
return result;
}
}
qDebug() << "app not found, permission granted";
O_INFO("app not found, permission granted");
return true;
}

Expand Down
130 changes: 65 additions & 65 deletions applications/system-service/application.cpp

Large diffs are not rendered by default.

122 changes: 55 additions & 67 deletions applications/system-service/appsapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,18 +106,18 @@ AppsAPI::AppsAPI(QObject* parent)
void AppsAPI::startup(){
Oxide::Sentry::sentry_transaction("apps", "startup", [this](Oxide::Sentry::Transaction* t){
if(applications.isEmpty()){
qDebug() << "No applications found";
O_INFO("No applications found");
notificationAPI->errorNotification(_noApplicationsMessage);
return;
}
Oxide::Sentry::sentry_span(t, "autoStart", "Launching auto start applications", [this](Oxide::Sentry::Span* s){
for(auto app : applications){
if(app->autoStart()){
qDebug() << "Auto starting" << app->name();
O_INFO("Auto starting" << app->name());
Oxide::Sentry::sentry_span(s, app->name().toStdString(), "Launching application", [app]{
app->launchNoSecurityCheck();
if(app->type() == Backgroundable){
qDebug() << " Pausing auto started app" << app->name();
O_INFO(" Pausing auto started app" << app->name());
app->pauseNoSecurityCheck();
}
});
Expand All @@ -127,28 +127,28 @@ void AppsAPI::startup(){
Oxide::Sentry::sentry_span(t, "start", "Launching initial application", [this]{
auto app = getApplication(m_lockscreenApplication);
if(app == nullptr){
qDebug() << "Could not find lockscreen application";
O_WARNING("Could not find lockscreen application");
app = getApplication(m_startupApplication);
}
if(app == nullptr){
qDebug() << "Could not find startup application";
qDebug() << "Using xochitl due to invalid configuration";
O_WARNING("Could not find startup application");
O_WARNING("Using xochitl due to invalid configuration");
app = getApplication("xochitl");
}
if(app == nullptr){
qDebug() << "Could not find xochitl";
qWarning() << "Using the first application in the list due to invalid configuration";
O_WARNING("Could not find xochitl");
O_WARNING("Using the first application in the list due to invalid configuration");
app = applications.first();
}
qDebug() << "Starting initial application" << app->name();
O_INFO("Starting initial application" << app->name());
app->launchNoSecurityCheck();
ensureForegroundApp();
});
});
}

void AppsAPI::setEnabled(bool enabled){
qDebug() << "Apps API" << enabled;
O_INFO("Apps API" << enabled);
for(auto app : applications){
if(enabled){
app->registerPath();
Expand All @@ -170,19 +170,19 @@ QDBusObjectPath AppsAPI::registerApplicationNoSecurityCheck(QVariantMap properti
QString bin = properties.value("bin", "").toString();
int type = properties.value("type", ApplicationType::Foreground).toInt();
if(type < ApplicationType::Foreground || type > ApplicationType::Backgroundable){
qDebug() << "Invalid configuration: Invalid type" << type;
O_WARNING("Invalid configuration: Invalid type" << type);
return QDBusObjectPath("/");
}
if(name.isEmpty()){
qDebug() << "Invalid configuration: Name is empty";
O_WARNING("Invalid configuration: Name is empty");
return QDBusObjectPath("/");
}
if(bin.isEmpty() || !QFile::exists(bin)){
qDebug() << "Invalid configuration: " << name << " has invalid bin" << bin;
O_WARNING("Invalid configuration: " << name << " has invalid bin" << bin);
return QDBusObjectPath("/");
}
if(!QFileInfo(bin).isExecutable()){
qDebug() << "Invalid configuration: " << name << " has bin that is not executable" << bin;
O_WARNING("Invalid configuration: " << name << " has bin that is not executable" << bin);
return QDBusObjectPath("/");
}
if(applications.contains(name)){
Expand Down Expand Up @@ -391,7 +391,7 @@ void AppsAPI::resumeIfNone(){
}
if(app == nullptr){
if(applications.isEmpty()){
qDebug() << "No applications found";
O_WARNING("No applications found");
notificationAPI->errorNotification(_noApplicationsMessage);
return;
}
Expand Down Expand Up @@ -465,7 +465,7 @@ bool AppsAPI::previousApplicationNoSecurityCheck(){
return false;
}
if(previousApplications.isEmpty()){
qDebug() << "No previous applications";
O_DEBUG("No previous applications");
return false;
}
bool found = false;
Expand All @@ -483,11 +483,11 @@ bool AppsAPI::previousApplicationNoSecurityCheck(){
currentApplication->pauseNoSecurityCheck(false);
}
application->launchNoSecurityCheck();
qDebug() << "Resuming previous application" << application->name();
O_INFO("Resuming previous application" << application->name());
found = true;
break;
}
qDebug() << "Previous Applications" << previousApplications;
O_DEBUG("Previous Applications" << previousApplications);
return found;
}

Expand All @@ -500,7 +500,7 @@ void AppsAPI::forceRecordPreviousApplication(){
auto name = currentApplication->name();
previousApplications.removeAll(name);
previousApplications.append(name);
qDebug() << "Previous Applications" << previousApplications;
O_DEBUG("Previous Applications" << previousApplications);
}

void AppsAPI::recordPreviousApplication(){
Expand All @@ -518,7 +518,7 @@ void AppsAPI::recordPreviousApplication(){
auto name = currentApplication->name();
removeFromPreviousApplications(name);
previousApplications.append(name);
qDebug() << "Previous Applications" << previousApplications;
O_DEBUG("Previous Applications" << previousApplications);
}

void AppsAPI::removeFromPreviousApplications(QString name){ previousApplications.removeAll(name); }
Expand All @@ -537,16 +537,16 @@ void AppsAPI::openDefaultApplication(){
&& currentApplication->stateNoSecurityCheck() != Application::Inactive
&& (path == m_startupApplication || path == m_lockscreenApplication)
){
qDebug() << "Already in default application";
O_DEBUG("Already in default application");
return;
}
}
auto app = getApplication(m_startupApplication);
if(app == nullptr){
qDebug() << "Unable to find default application";
O_WARNING("Unable to find default application");
return;
}
qDebug() << "Opening default application";
O_INFO("Opening default application");
app->launchNoSecurityCheck();
}

Expand All @@ -564,16 +564,16 @@ void AppsAPI::openTaskManager(){
&& currentApplication->stateNoSecurityCheck() != Application::Inactive
&& path == m_lockscreenApplication
){
qDebug() << "Can't open task manager, on the lockscreen";
O_WARNING("Can't open task manager, on the lockscreen");
return;
}
}
auto app = getApplication(m_processManagerApplication);
if(app == nullptr){
qDebug() << "Unable to find task manager";
O_WARNING("Unable to find task manager");
return;
}
qDebug() << "Opening task manager";
O_INFO("Opening task manager");
app->launchNoSecurityCheck();
}

Expand All @@ -589,16 +589,16 @@ void AppsAPI::openLockScreen(){
&& currentApplication->stateNoSecurityCheck() != Application::Inactive
&& path == m_lockscreenApplication
){
qDebug() << "Already on the lockscreen";
O_DEBUG("Already on the lockscreen");
return;
}
}
auto app = getApplication(m_lockscreenApplication);
if(app == nullptr){
qDebug() << "Unable to find lockscreen";
O_WARNING("Unable to find lockscreen");
return;
}
qDebug() << "Opening lock screen";
O_INFO("Opening lock screen");
app->launchNoSecurityCheck();
}

Expand All @@ -614,11 +614,11 @@ void AppsAPI::openTaskSwitcher(){
&& currentApplication->stateNoSecurityCheck() != Application::Inactive
){
if(path == m_lockscreenApplication){
qDebug() << "Can't open task switcher, on the lockscreen";
O_WARNING("Can't open task switcher, on the lockscreen");
return;
}
if(path == m_taskSwitcherApplication){
qDebug() << "Already on the task switcher";
O_WARNING("Already on the task switcher");
return;
}
}
Expand All @@ -630,10 +630,10 @@ void AppsAPI::openTaskSwitcher(){
}
app = getApplication(m_startupApplication);
if(app == nullptr){
qDebug() << "Unable to find default application";
O_WARNING("Unable to find default application");
return;
}
qDebug() << "Opening task switcher";
O_INFO("Opening task switcher");
app->launchNoSecurityCheck();
}

Expand All @@ -649,7 +649,7 @@ void AppsAPI::openTerminal(){
&& currentApplication->stateNoSecurityCheck() != Application::Inactive
){
if(path == m_lockscreenApplication){
qDebug() << "Can't open task switcher, on the lockscreen";
O_WARNING("Can't open task switcher, on the lockscreen");
return;
}
}
Expand All @@ -661,10 +661,10 @@ void AppsAPI::openTerminal(){
}
app = getApplication("fingerterm");
if(app == nullptr){
qDebug() << "Unable to find terminal application";
O_WARNING("Unable to find terminal application");
return;
}
qDebug() << "Opening terminal";
O_INFO("Opening terminal");
app->launchNoSecurityCheck();
}

Expand Down Expand Up @@ -722,9 +722,7 @@ void AppsAPI::readApplications(){
auto type = settings.value("type", Foreground).toInt();
auto bin = settings.value("bin").toString();
if(type < Foreground || type > Backgroundable || name.isEmpty() || bin.isEmpty()){
#ifdef DEBUG
qDebug() << "Invalid configuration " << name;
#endif
O_DEBUG("Invalid configuration " << name);
continue;
}
QVariantMap properties {
Expand All @@ -751,16 +749,12 @@ void AppsAPI::readApplications(){
properties.insert("group", settings.value("group", "").toString());
}
if(applications.contains(name)){
#ifdef DEBUG
qDebug() << "Updating " << name;
qDebug() << properties;
#endif
O_DEBUG("Updating " << name);
O_DEBUG(properties);
applications[name]->setConfig(properties);
}else{
qDebug() << name;
#ifdef DEBUG
qDebug() << properties;
#endif
O_INFO(name);
O_DEBUG(properties);
registerApplicationNoSecurityCheck(properties);
}
}
Expand All @@ -772,7 +766,7 @@ void AppsAPI::readApplications(){
for(auto entry : dir.entryInfoList()){
auto app = getRegistration(entry.filePath());
if(app.isEmpty()){
qDebug() << "Invalid file " << entry.filePath();
O_WARNING("Invalid file " << entry.filePath());
continue;
}
auto name = entry.completeBaseName();
Expand All @@ -783,7 +777,7 @@ void AppsAPI::readApplications(){
for(auto application : applications.values()){
auto name = application->name();
if(!apps.contains(name) && application->systemApp()){
qDebug() << name << "Is no longer found on disk";
O_WARNING(name << "Is no longer found on disk");
application->unregisterNoSecurityCheck();
}
}
Expand All @@ -792,10 +786,8 @@ void AppsAPI::readApplications(){
auto name = app["name"].toString();
auto bin = app["bin"].toString();
if(bin.isEmpty() || !QFile::exists(bin)){
qDebug() << name << "Can't find application binary:" << bin;
#ifdef DEBUG
qDebug() << app;
#endif
O_WARNING(name << "Can't find application binary:" << bin);
O_DEBUG(app);
continue;
}
if(!app.contains("flags") || !app["flags"].isArray()){
Expand All @@ -806,16 +798,12 @@ void AppsAPI::readApplications(){
app["flags"] = flags;
auto properties = registrationToMap(app);
if(applications.contains(name)){
#ifdef DEBUG
qDebug() << "Updating " << name;
qDebug() << properties;
#endif
O_DEBUG("Updating " << name);
O_DEBUG(properties);
applications[name]->setConfig(properties);
}else{
qDebug() << "New system app" << name;
#ifdef DEBUG
qDebug() << properties;
#endif
O_INFO("New system app" << name);
O_DEBUG(properties);
registerApplicationNoSecurityCheck(properties);
}
}
Expand Down Expand Up @@ -854,37 +842,37 @@ AppsAPI::~AppsAPI() {
settings.sync();
dispatchToMainThread([this] {
auto frameBuffer = EPFrameBuffer::framebuffer();
qDebug() << "Waiting for other painting to finish...";
O_DEBUG("Waiting for other painting to finish...");
while (frameBuffer->paintingActive()) {
EPFrameBuffer::waitForLastUpdate();
}
QPainter painter(frameBuffer);
auto rect = frameBuffer->rect();
auto fm = painter.fontMetrics();
qDebug() << "Clearing screen...";
O_INFO("Clearing screen...");
painter.setPen(Qt::white);
painter.fillRect(rect, Qt::black);
EPFrameBuffer::sendUpdate(rect, EPFrameBuffer::Mono, EPFrameBuffer::FullUpdate, true);
EPFrameBuffer::waitForLastUpdate();
painter.end();
qDebug() << "Stopping applications...";
O_DEBUG("Stopping applications...");
for (auto app : applications) {
if (app->stateNoSecurityCheck() != Application::Inactive) {
auto text = "Stopping " + app->displayName() + "...";
qDebug() << text.toStdString().c_str();
O_DEBUG(text.toStdString().c_str());
notificationAPI->drawNotificationText(text, Qt::white, Qt::black);
EPFrameBuffer::waitForLastUpdate();
}
app->stopNoSecurityCheck();
}
qDebug() << "Ensuring all applications have stopped...";
O_INFO("Ensuring all applications have stopped...");
for (auto app : applications) {
app->waitForFinished();
app->deleteLater();
}
applications.clear();
QPainter painter2(frameBuffer);
qDebug() << "Displaying final quit message...";
O_INFO("Displaying final quit message...");
painter2.fillRect(rect, Qt::black);
painter2.setPen(Qt::white);
if(systemAPI->landscape()){
Expand Down
Loading

0 comments on commit 3c85e2f

Please sign in to comment.