mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-02-10 05:38:32 -06:00
Redirect Qt messages to sqlite log mechanism
In Windows (related issue #1069) and maybe in macOS (related issue #1982) output to console is inhibited. This will allow these messages to be seen in our Error Log window.
This commit is contained in:
16
src/main.cpp
16
src/main.cpp
@@ -1,7 +1,23 @@
|
||||
#include "Application.h"
|
||||
#include "sqlite.h"
|
||||
|
||||
void db4sMessageOutput(QtMsgType type, const QMessageLogContext &, const QString &msg)
|
||||
{
|
||||
QByteArray localMsg = msg.toLocal8Bit();
|
||||
|
||||
// Emulate the default Qt treatment. This might not work in some OS, like Windows.
|
||||
fprintf(stderr, "%s\n", localMsg.constData());
|
||||
|
||||
// Log using the SQLite log mechanism, so it gets the same treatment than messages
|
||||
// reported by SQLite itself. This will allow these messages to be seen in our Log window.
|
||||
// Error code will be the type
|
||||
sqlite3_log(static_cast<int>(type), "%s\n", localMsg.constData());
|
||||
}
|
||||
|
||||
int main( int argc, char ** argv )
|
||||
{
|
||||
qInstallMessageHandler(db4sMessageOutput);
|
||||
|
||||
// Create application object. All the initialisation stuff happens in there
|
||||
Application a(argc, argv);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user