- Print logs into stout/stderr only if verbose is set.

- `--qt-logs-only` : print only logs from the application. It strips SDK logs from the output.
- Fix peer addresses in chat rooms (group/secure)
- Add an option to display the application debug logs.
This commit is contained in:
Julien Wadel 2023-03-30 15:07:45 +02:00
parent 982c54f6cf
commit c5225c6ccc
25 changed files with 235 additions and 31 deletions

View file

@ -25,6 +25,14 @@ Linphone is dual licensed, and is available either :
- [Linphone public wiki](https://wiki.linphone.org/xwiki/wiki/public/view/Linphone/)
### Parameters
`--help` : display available parameters.
`--verbose` : print logs into stdout/stderr.
`--qt-logs-only` : print only logs from the application. It strips SDK logs from the output.
## Getting started
Here are the general instructions to build Linphone for desktop. The specific instructions for each build platform is described just below.

View file

@ -117,6 +117,10 @@
<source>checkForUpdates</source>
<translation>Zkontrolovat aktualizace</translation>
</message>
<message>
<source>commandLineOptionQtLogsOnly</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>AssistantAbstractView</name>
@ -2575,6 +2579,9 @@ Klikněte zde: &lt;a href=&quot;%1&quot;&gt;%1&lt;/a&gt;
<translation>ZOBRAZIT</translation>
</message>
<message>
<source>fullLogsEnabledLabel</source>
<extracomment>&apos;Full logs&apos; : label for an option to activate all logs (debug and traces)</extracomment>
<translation type="unfinished"></translation>
<source>vfsTitle</source>
<extracomment>&apos;VFS&apos;</extracomment>
<translation>VFS</translation>

View file

@ -117,6 +117,10 @@
<source>checkForUpdates</source>
<translation>Tjek for opdateringer</translation>
</message>
<message>
<source>commandLineOptionQtLogsOnly</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>AssistantAbstractView</name>
@ -2389,6 +2393,11 @@ Klik her: &lt;a href=&quot;%1&quot;&gt;%1&lt;/a&gt;
<source>viewlogs</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>fullLogsEnabledLabel</source>
<extracomment>&apos;Full logs&apos; : label for an option to activate all logs (debug and traces)</extracomment>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SettingsAudio</name>

View file

@ -117,6 +117,10 @@
<source>checkForUpdates</source>
<translation>Auf Aktualisierungen prüfen</translation>
</message>
<message>
<source>commandLineOptionQtLogsOnly</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>AssistantAbstractView</name>
@ -2389,6 +2393,11 @@ Klicken Sie hier: &lt;a href=&quot;%1&quot;&gt;%1&lt;/a&gt;
<source>viewlogs</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>fullLogsEnabledLabel</source>
<extracomment>&apos;Full logs&apos; : label for an option to activate all logs (debug and traces)</extracomment>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SettingsAudio</name>

View file

@ -117,6 +117,10 @@
<source>checkForUpdates</source>
<translation>Check for updates</translation>
</message>
<message>
<source>commandLineOptionQtLogsOnly</source>
<translation>Print only logs from the application</translation>
</message>
</context>
<context>
<name>AssistantAbstractView</name>
@ -2389,6 +2393,12 @@ Click here: &lt;a href=&quot;%1&quot;&gt;%1&lt;/a&gt;
<source>viewlogs</source>
<translation>VIEW</translation>
</message>
<message>
<source>fullLogsEnabledLabel</source>
<extracomment>&apos;Full logs&apos; : label for an option to activate all logs (debug and traces)</extracomment>
<translatorcomment>&apos;Full logs&apos; : label for an option to activate all logs (debug and traces)</translatorcomment>
<translation>Full logs</translation>
</message>
</context>
<context>
<name>SettingsAudio</name>

View file

@ -117,6 +117,10 @@
<source>checkForUpdates</source>
<translation>Buscar actualizaciones</translation>
</message>
<message>
<source>commandLineOptionQtLogsOnly</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>AssistantAbstractView</name>
@ -2389,6 +2393,11 @@ Haga clic aquí: &lt;a href=&quot;%1&quot;&gt;%1 &lt;/a&gt;
<source>viewlogs</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>fullLogsEnabledLabel</source>
<extracomment>&apos;Full logs&apos; : label for an option to activate all logs (debug and traces)</extracomment>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SettingsAudio</name>

View file

@ -117,6 +117,10 @@
<source>checkForUpdates</source>
<translation>Vérifier les mises à jour</translation>
</message>
<message>
<source>commandLineOptionQtLogsOnly</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>AssistantAbstractView</name>
@ -2406,6 +2410,9 @@ Cliquez ici : &lt;a href=&quot;%1&quot;&gt;%1&lt;/a&gt;
<translation>AFFICHER</translation>
</message>
<message>
<source>fullLogsEnabledLabel</source>
<extracomment>&apos;Full logs&apos; : label for an option to activate all logs (debug and traces)</extracomment>
<translation type="unfinished"></translation>
<source>vfsTitle</source>
<extracomment>&apos;VFS&apos;</extracomment>
<translation>VFS</translation>

View file

@ -117,6 +117,10 @@
<source>checkForUpdates</source>
<translation>Frissítések keresése</translation>
</message>
<message>
<source>commandLineOptionQtLogsOnly</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>AssistantAbstractView</name>
@ -2376,6 +2380,11 @@ Kattintson ide: &lt;a href=&quot;%1&quot;&gt;%1&lt;/a&gt;
<source>viewlogs</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>fullLogsEnabledLabel</source>
<extracomment>&apos;Full logs&apos; : label for an option to activate all logs (debug and traces)</extracomment>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SettingsAudio</name>

View file

@ -117,6 +117,10 @@
<source>checkForUpdates</source>
<translation>Cerca aggiornamenti</translation>
</message>
<message>
<source>commandLineOptionQtLogsOnly</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>AssistantAbstractView</name>
@ -2389,6 +2393,11 @@ Clicca: &lt;a href=&quot;%1&quot;&gt;%1&lt;/a&gt;
<source>viewlogs</source>
<translation>VISTA</translation>
</message>
<message>
<source>fullLogsEnabledLabel</source>
<extracomment>&apos;Full logs&apos; : label for an option to activate all logs (debug and traces)</extracomment>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SettingsAudio</name>

View file

@ -117,6 +117,10 @@
<source>checkForUpdates</source>
<translation></translation>
</message>
<message>
<source>commandLineOptionQtLogsOnly</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>AssistantAbstractView</name>
@ -2376,6 +2380,11 @@
<source>viewlogs</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>fullLogsEnabledLabel</source>
<extracomment>&apos;Full logs&apos; : label for an option to activate all logs (debug and traces)</extracomment>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SettingsAudio</name>

View file

@ -117,6 +117,10 @@
<source>checkForUpdates</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>commandLineOptionQtLogsOnly</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>AssistantAbstractView</name>
@ -2402,6 +2406,11 @@ Spustelėkite čia: &lt;a href=&quot;%1&quot;&gt;%1&lt;/a&gt;
<source>viewlogs</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>fullLogsEnabledLabel</source>
<extracomment>&apos;Full logs&apos; : label for an option to activate all logs (debug and traces)</extracomment>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SettingsAudio</name>

View file

@ -117,6 +117,10 @@
<source>checkForUpdates</source>
<translation type="unfinished">Verifique se atualizações</translation>
</message>
<message>
<source>commandLineOptionQtLogsOnly</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>AssistantAbstractView</name>
@ -2389,6 +2393,11 @@ Clique aqui: &lt;a href=&quot;%1&quot;&gt;%1 &lt;/a&gt;
<source>viewlogs</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>fullLogsEnabledLabel</source>
<extracomment>&apos;Full logs&apos; : label for an option to activate all logs (debug and traces)</extracomment>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SettingsAudio</name>

View file

@ -117,6 +117,10 @@
<source>checkForUpdates</source>
<translation>Проверить обновления</translation>
</message>
<message>
<source>commandLineOptionQtLogsOnly</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>AssistantAbstractView</name>
@ -2419,6 +2423,9 @@
<translation>ВИД</translation>
</message>
<message>
<source>fullLogsEnabledLabel</source>
<extracomment>&apos;Full logs&apos; : label for an option to activate all logs (debug and traces)</extracomment>
<translation type="unfinished"></translation>
<source>vfsTitle</source>
<extracomment>&apos;VFS&apos;</extracomment>
<translation>ВФС</translation>

View file

@ -117,6 +117,10 @@
<source>checkForUpdates</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>commandLineOptionQtLogsOnly</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>AssistantAbstractView</name>
@ -2389,6 +2393,11 @@ Klicka här: &lt;a href=&quot;%1&quot;&gt;%1&lt;/a&gt;
<source>viewlogs</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>fullLogsEnabledLabel</source>
<extracomment>&apos;Full logs&apos; : label for an option to activate all logs (debug and traces)</extracomment>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SettingsAudio</name>

View file

@ -117,6 +117,10 @@
<source>checkForUpdates</source>
<translation>Güncellemeleri denetle</translation>
</message>
<message>
<source>commandLineOptionQtLogsOnly</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>AssistantAbstractView</name>
@ -2376,6 +2380,11 @@ Buraya tıklayın: &lt;a href=&quot;%1&quot;&gt;%1&lt;/a&gt;
<source>viewlogs</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>fullLogsEnabledLabel</source>
<extracomment>&apos;Full logs&apos; : label for an option to activate all logs (debug and traces)</extracomment>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SettingsAudio</name>

View file

@ -117,6 +117,10 @@
<source>checkForUpdates</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>commandLineOptionQtLogsOnly</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>AssistantAbstractView</name>
@ -2402,6 +2406,11 @@
<source>viewlogs</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>fullLogsEnabledLabel</source>
<extracomment>&apos;Full logs&apos; : label for an option to activate all logs (debug and traces)</extracomment>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SettingsAudio</name>

View file

@ -117,6 +117,10 @@
<source>checkForUpdates</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>commandLineOptionQtLogsOnly</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>AssistantAbstractView</name>
@ -2376,6 +2380,11 @@
<source>viewlogs</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>fullLogsEnabledLabel</source>
<extracomment>&apos;Full logs&apos; : label for an option to activate all logs (debug and traces)</extracomment>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SettingsAudio</name>

View file

@ -234,6 +234,8 @@ App::App (int &argc, char *argv[]) : SingleApplication(argc, argv, true, Mode::U
if (mParser->isSet("verbose"))
Logger::getInstance()->setVerbose(true);
if (mParser->isSet("qt-logs-only"))
Logger::getInstance()->enableQtOnly(true);
// List available locales.
for (const auto &locale : QDir(Constants::LanguagePath).entryList())
@ -562,7 +564,8 @@ void App::createParser () {
#ifndef Q_OS_MACOS
{ "iconified", tr("commandLineOptionIconified") },
#endif // ifndef Q_OS_MACOS
{ { "V", "verbose" }, tr("commandLineOptionVerbose") }
{ { "V", "verbose" }, tr("commandLineOptionVerbose") },
{ "qt-logs-only", tr("commandLineOptionQtLogsOnly") },
});
}

View file

@ -63,7 +63,7 @@ static inline QByteArray getFormattedCurrentTime () {
}
// -----------------------------------------------------------------------------
// Called from SDK
class LinphoneLogger : public linphone::LoggingServiceListener {
public:
LinphoneLogger (const Logger *logger) : mLogger(logger) {}
@ -75,40 +75,43 @@ private:
linphone::LogLevel level,
const string &message
) override {
if (!mLogger->isVerbose())
bool isQtLog = domain==Constants::QtDomain;
if (!mLogger->isVerbose() || (!isQtLog && mLogger->qtOnlyEnabled()))
return;
FILE * out = stdout;
using LogLevel = linphone::LogLevel;
const char *format;
QString format = (isQtLog ? PURPLE : YELLOW ) + QString("Core:%s: " RESET "%s\n");
switch (level) {
case LogLevel::Debug:
format = GREEN "[%s][Debug]" YELLOW "Core:%s: " RESET "%s\n";
format.prepend(GREEN "[%s][Debug]");
break;
case LogLevel::Trace:
format = BLUE "[%s][Trace]" YELLOW "Core:%s: " RESET "%s\n";
format.prepend(BLUE "[%s][Trace]");
break;
case LogLevel::Message:
format = BLUE "[%s][Info]" YELLOW "Core:%s: " RESET "%s\n";
format.prepend(BLUE "[%s][Info]");
break;
case LogLevel::Warning:
format = RED "[%s][Warning]" YELLOW "Core:%s: " RESET "%s\n";
format.prepend(RED "[%s][Warning]");
out = stderr;
break;
case LogLevel::Error:
format = RED "[%s][Error]" YELLOW "Core:%s: " RESET "%s\n";
format.prepend(RED "[%s][Error]");
out = stderr;
break;
case LogLevel::Fatal:
format = RED "[%s][Fatal]" YELLOW "Core:%s: " RESET "%s\n";
format.prepend(RED "[%s][Fatal]");
out = stderr;
break;
}
fprintf(
stderr,
format,
fprintf( out,
qPrintable(format),
getFormattedCurrentTime().constData(),
domain.empty() ? domain.c_str() : EXECUTABLE_NAME,
message.c_str()
);
fflush(out);
if (level == LogLevel::Fatal)
terminate();
};
@ -117,7 +120,7 @@ private:
};
// -----------------------------------------------------------------------------
// Called from Qt
void Logger::log (QtMsgType type, const QMessageLogContext &context, const QString &msg) {
const char *format;
BctbxLogLevel level;
@ -163,8 +166,6 @@ void Logger::log (QtMsgType type, const QMessageLogContext &context, const QStri
mMutex.lock();
fprintf(stdout, format, dateTime.constData(), QThread::currentThread(), contextStr, localMsg.constData());
fflush(stdout);
if( level == BCTBX_LOG_FATAL)
QMessageBox::critical(nullptr, "Linphone will crash", msg); // Print an error message before sending msg to bctoolbox
bctbx_log(Constants::QtDomain, level, "QT: %s%s", contextStr, localMsg.constData());
@ -210,7 +211,26 @@ void Logger::init (const shared_ptr<linphone::Config> &config) {
linphone::Core::setLogCollectionPath(Utils::appStringToCoreString(folder));
linphone::Core::setLogCollectionMaxFileSize(Constants::MaxLogsCollectionSize);
mInstance->enableFullLogs(SettingsModel::getFullLogsEnabled(config));
mInstance->enable(SettingsModel::getLogsEnabled(config));
}
void Logger::enableFullLogs(const bool& full){
if(mLoggingService){
mLoggingService->setLogLevel(full ? linphone::LogLevel::Debug : linphone::LogLevel::Message);
}
}
bool Logger::qtOnlyEnabled() const{
return mQtOnly;
}
void Logger::enableQtOnly(const bool& enable){
mQtOnly = enable;
if(mLoggingService){
mLoggingService->setDomain(enable ? Constants::QtDomain : "");
}
}
QString Logger::getLogText()const{

View file

@ -44,19 +44,24 @@ public:
void enable (bool status);
QString getLogText()const;
void enableFullLogs(const bool& full);
bool qtOnlyEnabled() const;
void enableQtOnly(const bool& enable);
static void init (const std::shared_ptr<linphone::Config> &config);
static Logger *getInstance () {
return mInstance;
}
private:
Logger () = default;
static void log (QtMsgType type, const QMessageLogContext &context, const QString &msg);
bool mVerbose = false;
bool mQtOnly = false;
static QMutex mMutex;
static Logger *mInstance;

View file

@ -100,11 +100,11 @@ VcardModel::VcardModel (shared_ptr<linphone::Vcard> vcard, bool isReadOnly) : QO
VcardModel::~VcardModel () {
if (!mIsReadOnly) {
qInfo() << QStringLiteral("Destroy detached vcard:") << this;
qDebug() << QStringLiteral("Destroy detached vcard:") << this;
if (!mAvatarIsReadOnly)
removeBelcardPhoto(mVcard->getVcard());
} else
qInfo() << QStringLiteral("Destroy attached vcard:") << this;
qDebug() << QStringLiteral("Destroy attached vcard:") << this;
}
// -----------------------------------------------------------------------------

View file

@ -578,15 +578,15 @@ QVariantMap SettingsModel::getVideoDefinition () const {
}
QVariantMap SettingsModel::getCurrentPreviewVideoDefinition () const {
auto definition = CoreManager::getInstance()->getCore()->getCurrentPreviewVideoDefinition();
if(definition)
return createMapFromVideoDefinition(definition);
else {
QVariantMap map;
map["width"] = 0;
map["height"] = 0;
return map;
if(CoreManager::getInstance()->getCore()->videoPreviewEnabled()){
auto definition = CoreManager::getInstance()->getCore()->getCurrentPreviewVideoDefinition();
if(definition)
return createMapFromVideoDefinition(definition);
}
QVariantMap map;
map["width"] = 0;
map["height"] = 0;
return map;
}
void SettingsModel::setVideoDefinition (const QVariantMap &definition) {
@ -1685,6 +1685,16 @@ void SettingsModel::setLogsEnabled (bool status) {
emit logsEnabledChanged(status);
}
bool SettingsModel::getFullLogsEnabled () const {
return getFullLogsEnabled(mConfig);
}
void SettingsModel::setFullLogsEnabled (bool status) {
mConfig->setInt(UiSection, "full_logs_enabled", status);
Logger::getInstance()->enableFullLogs(status);
emit fullLogsEnabledChanged();
}
// ---------------------------------------------------------------------------
QString SettingsModel::getLogsEmail () const {
@ -1714,6 +1724,9 @@ bool SettingsModel::getLogsEnabled (const shared_ptr<linphone::Config> &config)
return config ? config->getInt(UiSection, "logs_enabled", false) : true;
}
bool SettingsModel::getFullLogsEnabled (const shared_ptr<linphone::Config> &config) {
return config ? config->getInt(UiSection, "full_logs_enabled", false) : false;
}
// ---------------------------------------------------------------------------
bool SettingsModel::isDeveloperSettingsAvailable() const {
#ifdef DEBUG

View file

@ -219,6 +219,7 @@ class SettingsModel : public QObject {
Q_PROPERTY(QString logsFolder READ getLogsFolder WRITE setLogsFolder NOTIFY logsFolderChanged)
Q_PROPERTY(QString logsUploadUrl READ getLogsUploadUrl WRITE setLogsUploadUrl NOTIFY logsUploadUrlChanged)
Q_PROPERTY(bool logsEnabled READ getLogsEnabled WRITE setLogsEnabled NOTIFY logsEnabledChanged)
Q_PROPERTY(bool fullLogsEnabled READ getFullLogsEnabled WRITE setFullLogsEnabled NOTIFY fullLogsEnabledChanged)
Q_PROPERTY(QString logsEmail READ getLogsEmail WRITE setLogsEmail NOTIFY logsEmailChanged)
Q_PROPERTY(bool developerSettingsEnabled READ getDeveloperSettingsEnabled WRITE setDeveloperSettingsEnabled NOTIFY developerSettingsEnabledChanged)
@ -608,6 +609,9 @@ public:
bool getLogsEnabled () const;
void setLogsEnabled (bool status);
bool getFullLogsEnabled () const;
void setFullLogsEnabled (bool status);
QString getLogsEmail () const;
void setLogsEmail (const QString &email);
@ -617,6 +621,7 @@ public:
static QString getLogsFolder (const std::shared_ptr<linphone::Config> &config);
static bool getLogsEnabled (const std::shared_ptr<linphone::Config> &config);
static bool getFullLogsEnabled (const std::shared_ptr<linphone::Config> &config);
// ---------------------------------------------------------------------------
Q_INVOKABLE bool isDeveloperSettingsAvailable() const;
@ -797,6 +802,7 @@ signals:
void logsFolderChanged (const QString &folder);
void logsUploadUrlChanged (const QString &url);
void logsEnabledChanged (bool status);
void fullLogsEnabledChanged ();
void logsEmailChanged (const QString &email);
void contactImporterChanged();

View file

@ -45,7 +45,7 @@ ColumnLayout {
function getPeerAddress() {
if(chatRoomModel) {
if(chatRoomModel.groupEnabled || chatRoomModel.isSecure()) {
return chatRoomModel.participants.addressesToString;
return chatRoomModel.getPeerAddress();
}else {
return chatRoomModel.sipAddress;
}
@ -56,7 +56,7 @@ ColumnLayout {
function getFullPeerAddress() {
if(chatRoomModel) {
if(chatRoomModel.groupEnabled || chatRoomModel.isSecure()) {
return chatRoomModel.participants.addressesToString;
return chatRoomModel.getFullPeerAddress()
}else {
return chatRoomModel.sipAddress;
}

View file

@ -68,6 +68,16 @@ TabContainer {
onClicked: SettingsModel.logsEnabled = !checked
}
}
FormGroup {
//: 'Full logs' : label for an option to activate all logs (debug and traces)
label: qsTr('fullLogsEnabledLabel')
Switch {
checked: SettingsModel.fullLogsEnabled
onClicked: SettingsModel.fullLogsEnabled = !checked
}
}
}
}
Row {