forked from openkylin/ukui-search
commit
183a147d85
|
@ -17,7 +17,8 @@ Build-Depends: debhelper (>=9.0.0),
|
||||||
libgsettings-qt-dev,
|
libgsettings-qt-dev,
|
||||||
libqt5x11extras5-dev,
|
libqt5x11extras5-dev,
|
||||||
libuchardet-dev,
|
libuchardet-dev,
|
||||||
libpoppler-qt5-dev
|
libpoppler-qt5-dev,
|
||||||
|
libukui-log4qt-dev
|
||||||
Standards-Version: 4.5.0
|
Standards-Version: 4.5.0
|
||||||
Homepage: https://www.ukui.org/
|
Homepage: https://www.ukui.org/
|
||||||
Vcs-Git: https://github.com/ukui/ukui-search.git
|
Vcs-Git: https://github.com/ukui/ukui-search.git
|
||||||
|
|
86
src/main.cpp
86
src/main.cpp
|
@ -29,6 +29,7 @@
|
||||||
#include <QLocale>
|
#include <QLocale>
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <syslog.h>
|
#include <syslog.h>
|
||||||
|
#include <ukui-log4qt.h>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include "qt-single-application.h"
|
#include "qt-single-application.h"
|
||||||
#include "qt-local-peer.h"
|
#include "qt-local-peer.h"
|
||||||
|
@ -61,50 +62,50 @@
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
|
||||||
void messageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg)
|
//void messageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg)
|
||||||
{
|
//{
|
||||||
QByteArray localMsg = msg.toLocal8Bit();
|
// QByteArray localMsg = msg.toLocal8Bit();
|
||||||
QByteArray currentTime = QTime::currentTime().toString().toLocal8Bit();
|
// QByteArray currentTime = QTime::currentTime().toString().toLocal8Bit();
|
||||||
|
|
||||||
bool showDebug = true;
|
// bool showDebug = true;
|
||||||
// QString logFilePath = QStandardPaths::writableLocation(QStandardPaths::TempLocation) + "/ukui-search.log";
|
//// QString logFilePath = QStandardPaths::writableLocation(QStandardPaths::TempLocation) + "/ukui-search.log";
|
||||||
// QString logFilePath = QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + "/.config/org.ukui/ukui-search/ukui-search.log";
|
//// QString logFilePath = QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + "/.config/org.ukui/ukui-search/ukui-search.log";
|
||||||
QString logFilePath = QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + "/.config/org.ukui/ukui-search.log";
|
// QString logFilePath = QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + "/.config/org.ukui/ukui-search.log";
|
||||||
if (!QFile::exists(logFilePath)) {
|
// if (!QFile::exists(logFilePath)) {
|
||||||
showDebug = false;
|
// showDebug = false;
|
||||||
}
|
// }
|
||||||
FILE *log_file = nullptr;
|
// FILE *log_file = nullptr;
|
||||||
|
|
||||||
if (showDebug) {
|
// if (showDebug) {
|
||||||
log_file = fopen(logFilePath.toLocal8Bit().constData(), "a+");
|
// log_file = fopen(logFilePath.toLocal8Bit().constData(), "a+");
|
||||||
}
|
// }
|
||||||
|
|
||||||
const char *file = context.file ? context.file : "";
|
// const char *file = context.file ? context.file : "";
|
||||||
const char *function = context.function ? context.function : "";
|
// const char *function = context.function ? context.function : "";
|
||||||
switch (type) {
|
// switch (type) {
|
||||||
case QtDebugMsg:
|
// case QtDebugMsg:
|
||||||
if (!log_file) {
|
// if (!log_file) {
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
fprintf(log_file, "Debug: %s: %s (%s:%u, %s)\n", currentTime.constData(), localMsg.constData(), file, context.line, function);
|
// fprintf(log_file, "Debug: %s: %s (%s:%u, %s)\n", currentTime.constData(), localMsg.constData(), file, context.line, function);
|
||||||
break;
|
// break;
|
||||||
case QtInfoMsg:
|
// case QtInfoMsg:
|
||||||
fprintf(log_file? log_file: stdout, "Info: %s: %s (%s:%u, %s)\n", currentTime.constData(), localMsg.constData(), file, context.line, function);
|
// fprintf(log_file? log_file: stdout, "Info: %s: %s (%s:%u, %s)\n", currentTime.constData(), localMsg.constData(), file, context.line, function);
|
||||||
break;
|
// break;
|
||||||
case QtWarningMsg:
|
// case QtWarningMsg:
|
||||||
fprintf(log_file? log_file: stderr, "Warning: %s: %s (%s:%u, %s)\n", currentTime.constData(), localMsg.constData(), file, context.line, function);
|
// fprintf(log_file? log_file: stderr, "Warning: %s: %s (%s:%u, %s)\n", currentTime.constData(), localMsg.constData(), file, context.line, function);
|
||||||
break;
|
// break;
|
||||||
case QtCriticalMsg:
|
// case QtCriticalMsg:
|
||||||
fprintf(log_file? log_file: stderr, "Critical: %s: %s (%s:%u, %s)\n", currentTime.constData(), localMsg.constData(), file, context.line, function);
|
// fprintf(log_file? log_file: stderr, "Critical: %s: %s (%s:%u, %s)\n", currentTime.constData(), localMsg.constData(), file, context.line, function);
|
||||||
break;
|
// break;
|
||||||
case QtFatalMsg:
|
// case QtFatalMsg:
|
||||||
fprintf(log_file? log_file: stderr, "Fatal: %s: %s (%s:%u, %s)\n", currentTime.constData(), localMsg.constData(), file, context.line, function);
|
// fprintf(log_file? log_file: stderr, "Fatal: %s: %s (%s:%u, %s)\n", currentTime.constData(), localMsg.constData(), file, context.line, function);
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (log_file)
|
// if (log_file)
|
||||||
fclose(log_file);
|
// fclose(log_file);
|
||||||
}
|
//}
|
||||||
|
|
||||||
void centerToScreen(QWidget* widget) {
|
void centerToScreen(QWidget* widget) {
|
||||||
if (!widget)
|
if (!widget)
|
||||||
|
@ -144,6 +145,9 @@ void searchMethod(FileUtils::SearchMethod sm){
|
||||||
*/
|
*/
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
//Init log module
|
||||||
|
initUkuiLog4qt("ukui-search");
|
||||||
|
|
||||||
// Determine whether the home directory has been created, and if not, keep waiting.
|
// Determine whether the home directory has been created, and if not, keep waiting.
|
||||||
char *p_home = NULL;
|
char *p_home = NULL;
|
||||||
|
|
||||||
|
@ -170,7 +174,7 @@ int main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
// Output log to file
|
// Output log to file
|
||||||
qInstallMessageHandler(messageOutput);
|
// qInstallMessageHandler(messageOutput);
|
||||||
|
|
||||||
// Register meta type
|
// Register meta type
|
||||||
qDebug() << "ukui-search main start";
|
qDebug() << "ukui-search main start";
|
||||||
|
|
|
@ -9,6 +9,7 @@ TEMPLATE = app
|
||||||
PKGCONFIG += gio-2.0 glib-2.0 gio-unix-2.0
|
PKGCONFIG += gio-2.0 glib-2.0 gio-unix-2.0
|
||||||
CONFIG += c++11 link_pkgconfig no_keywords lrelease
|
CONFIG += c++11 link_pkgconfig no_keywords lrelease
|
||||||
LIBS += -lxapian -lgsettings-qt -lquazip5 -lX11
|
LIBS += -lxapian -lgsettings-qt -lquazip5 -lX11
|
||||||
|
LIBS += -lukui-log4qt
|
||||||
# The following define makes your compiler emit warnings if you use
|
# The following define makes your compiler emit warnings if you use
|
||||||
# any Qt feature that has been marked deprecated (the exact warnings
|
# any Qt feature that has been marked deprecated (the exact warnings
|
||||||
# depend on your compiler). Please consult the documentation of the
|
# depend on your compiler). Please consult the documentation of the
|
||||||
|
|
|
@ -20,13 +20,11 @@
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QDBusConnection>
|
#include <QDBusConnection>
|
||||||
#include <QDBusError>
|
#include <QDBusError>
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
#include "sysdbusregister.h"
|
#include "sysdbusregister.h"
|
||||||
|
|
||||||
int main(int argc, char *argv[]){
|
int main(int argc, char *argv[]){
|
||||||
|
|
||||||
QCoreApplication app(argc, argv);
|
QCoreApplication app(argc, argv);
|
||||||
app.setOrganizationName("Kylin Team");
|
app.setOrganizationName("Kylin Team");
|
||||||
app.setApplicationName("ukui-search-service");
|
app.setApplicationName("ukui-search-service");
|
||||||
|
|
Loading…
Reference in New Issue