Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[debug] internal logging; view log in GUI; verbose logging infrastructure #392

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions avidemux/cli/ADM_userInterfaces/ADM_dialog/DIA_none.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ uint8_t DIA_RecentFiles( char **name ) {return 0;}
uint8_t DIA_about( void ) {return 0;}
void DIA_Calculator(uint32_t *sizeInMeg, uint32_t *avgBitrate ) {}
void DIA_properties(void) {}
void DIA_log(void) {}
int GUI_handleVFilter (void) {return 0;}
uint8_t initGUI(const vector<IScriptEngine*>& scriptEngines) {return 1;}
void destroyGUI(void) {}
Expand Down
10 changes: 8 additions & 2 deletions avidemux/common/ADM_commonUI/DIA_prefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ uint32_t playbackPriority=0;
uint32_t downmix;
bool mpeg_no_limit=0;
uint32_t msglevel=2;
bool logVerbosity=false;

uint32_t mixer=0;
bool doAutoUpdate=false;
Expand Down Expand Up @@ -249,6 +250,8 @@ std::string currentSdlDriver=getSdlDriverName();
useSwap=0;
// Get level of message verbosity
prefs->get(MESSAGE_LEVEL,&msglevel);
// Get logging verbosity
prefs->get(VERBOSE_LOG,&logVerbosity);
// Downmix default
if(prefs->get(DEFAULT_DOWNMIXING,&downmix)!=RC_OK)
{
Expand All @@ -263,7 +266,7 @@ std::string currentSdlDriver=getSdlDriverName();
diaElemToggle swapUpDownKeys(&swapUpDown,QT_TRANSLATE_NOOP("adm","Re_verse UP and DOWN arrow keys for navigation"));
diaElemToggle swapMarkers(&useSwap,QT_TRANSLATE_NOOP("adm","_Swap markers if marker A is set past marker B or marker B before A in video"));
diaElemToggle checkForUpdate(&doAutoUpdate,QT_TRANSLATE_NOOP("adm","_Check for new release"));

diaElemToggle enableVerboseLog(&logVerbosity,QT_TRANSLATE_NOOP("adm","Verbose debug logging"));

diaElemFrame frameSimd(QT_TRANSLATE_NOOP("adm","SIMD"));

Expand Down Expand Up @@ -497,7 +500,7 @@ std::string currentSdlDriver=getSdlDriverName();
//--
#define NB_ELEM(x) sizeof(x)/sizeof(diaElem *)
/* User Interface */
diaElem *diaUser[]={&menuMessage, &menuLanguage, &resetEncoder, &enableAltShortcuts, &swapUpDownKeys, &swapMarkers, &checkForUpdate};
diaElem *diaUser[]={&menuMessage, &menuLanguage, &resetEncoder, &enableAltShortcuts, &swapUpDownKeys, &swapMarkers, &checkForUpdate, &enableVerboseLog};
diaElemTabs tabUser(QT_TRANSLATE_NOOP("adm","User Interface"),NB_ELEM(diaUser),diaUser);

/* Automation */
Expand Down Expand Up @@ -757,6 +760,9 @@ std::string currentSdlDriver=getSdlDriverName();
prefs->set(FEATURES_SWAP_IF_A_GREATER_THAN_B, useSwap);
//
prefs->set(MESSAGE_LEVEL,msglevel);

prefs->set(VERBOSE_LOG,logVerbosity);
ADM_setVerboseLog(logVerbosity);
// Discard changes to output config on video load
prefs->set(RESET_ENCODER_ON_VIDEO_LOAD, loadDefault);
#ifdef USE_VDPAU
Expand Down
1 change: 1 addition & 0 deletions avidemux/common/ADM_commonUI/myOwnMenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ std::vector<MenuEntry> myMenuAudio(_myMenuAudio, _myMenuAudio + sizeof(_myMenuAu
static const MenuEntry _myMenuHelp[] = {
{MENU_ACTION,QT_TRANSLATE_NOOP("adm","Build Option"), NULL,ACT_BUILT_IN, NULL,NULL,0},
{MENU_ACTION,QT_TRANSLATE_NOOP("adm","Plugins"), NULL,ACT_PLUGIN_INFO, NULL,NULL,0},
{MENU_ACTION,QT_TRANSLATE_NOOP("adm","Log"), NULL,ACT_DEBUG_LOG, NULL,NULL,0},
#ifdef _WIN32
{MENU_SEPARATOR,"-",NULL,ACT_DUMMY,NULL,NULL,1},
{MENU_SUBMENU,QT_TRANSLATE_NOOP("adm","&Advanced"), NULL,ACT_DUMMY, NULL,NULL,0},
Expand Down
1 change: 1 addition & 0 deletions avidemux/common/gui_action.names
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ ACT(HEX_DUMP)
ACT(SIZE_DUMP)
ACT(AVS_PROXY)
ACT(JOG)
ACT(DEBUG_LOG)
ACT(OPEN_APP_LOG)
ACT(OPEN_APP_FOLDER)

Expand Down
4 changes: 4 additions & 0 deletions avidemux/common/gui_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ extern bool GUI_infiniteForward(uint64_t pts);
//***********************************
extern uint8_t DIA_about( void );
extern void DIA_properties( void);
extern void DIA_log( void);
extern uint8_t DIA_Preferences(void);
extern uint8_t DIA_builtin(void);
extern uint8_t DIA_pluginsInfo(void);
Expand Down Expand Up @@ -295,6 +296,9 @@ void HandleAction (Action action)
case ACT_PLUGIN_INFO:
DIA_pluginsInfo();
return;
case ACT_DEBUG_LOG:
DIA_log();
return;
case ACT_OPEN_APP_LOG:
GUI_OpenApplicationLog();
return;
Expand Down
6 changes: 5 additions & 1 deletion avidemux/common/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ int main(int _argc, char *_argv[]);

int main(int _argc, char *_argv[])
{
ADM_debugInit();
ADM_initBaseDir(_argc, _argv);

#if defined(_WIN32) && (ADM_UI_TYPE_BUILD == ADM_UI_GTK || ADM_UI_TYPE_BUILD == ADM_UI_QT4)
Expand Down Expand Up @@ -116,7 +117,7 @@ int main(int _argc, char *_argv[])
#endif

uninstallSigHandler();

ADM_debugFree();
return exitVal;
}
/**
Expand Down Expand Up @@ -279,6 +280,9 @@ int startAvidemux(int argc, char *argv[])
{
setPrefsDefault();
}
bool verboseLog=false;
prefs->get(VERBOSE_LOG,&verboseLog);
ADM_setVerboseLog(verboseLog);
uint32_t cpuMask;
if(!prefs->get(FEATURES_CPU_CAPS,&cpuMask))
{
Expand Down
3 changes: 3 additions & 0 deletions avidemux/qt4/ADM_userInterfaces/ADM_dialog/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ SET(
#calculator.ui
encoding.ui
license.ui
log.ui
jobs.ui
props.ui
#vobsub.ui
Expand All @@ -21,6 +22,7 @@ SET(headers
Q_audioTracks.h
Q_audioTrackClass.h
Q_license.h
Q_log.h
Q_jobs.h
Q_props.h
#Q_vobsub.h
Expand All @@ -37,6 +39,7 @@ SET(${ADM_LIB}_SRCS ${${ADM_LIB}_SRCS}
${${ADM_LIB}_headers} ${${ADM_LIB}_source} ${${ADM_LIB}_resource}
Q_about.cpp
Q_license.cpp
Q_log.cpp
Q_jobs.cpp
Q_props.cpp
Q_working.cpp
Expand Down
46 changes: 46 additions & 0 deletions avidemux/qt4/ADM_userInterfaces/ADM_dialog/Q_log.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/***************************************************************************
Q_log.cpp
-----------

copyright : (C) 2021 szlldm
***************************************************************************/

/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "ADM_default.h"
#include "ADM_inttype.h"
#include "Q_log.h"
#include "ADM_toolkitQt.h"
#include <QScrollBar>

Ui_logWindow::Ui_logWindow(QWidget *parent) : QDialog(parent)
{
ui.setupUi(this);
const char * log = ADM_debugLogRead();
if (log==NULL)
log="error";
QFont font("Monospace");
font.setPointSize(8);
font.setStyleHint(QFont::TypeWriter);
QTextDocument *doc = ui.logTextEdit->document();
doc->setDefaultFont(font);
ui.logTextEdit->setLineWrapMode(QTextEdit::NoWrap);
ui.logTextEdit->setPlainText(QString(log));
ui.logTextEdit->moveCursor(QTextCursor::End);
ui.logTextEdit->ensureCursorVisible();
}

void DIA_log(void)
{
Ui_logWindow dialog(qtLastRegisteredDialog());

qtRegisterDialog(&dialog);
dialog.exec();
qtUnregisterDialog(&dialog);
}
17 changes: 17 additions & 0 deletions avidemux/qt4/ADM_userInterfaces/ADM_dialog/Q_log.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#ifndef Q_log_h
#define Q_log_h

#include "ui_log.h"

class Ui_logWindow : public QDialog
{
Q_OBJECT

private:
Ui_logDialog ui;

public:
Ui_logWindow(QWidget *parent);
};

#endif // Q_log_h
110 changes: 110 additions & 0 deletions avidemux/qt4/ADM_userInterfaces/ADM_dialog/log.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>logDialog</class>
<widget class="QDialog" name="logDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>624</width>
<height>422</height>
</rect>
</property>
<property name="windowTitle">
<string>Debug log</string>
</property>
<layout class="QVBoxLayout">
<property name="spacing">
<number>6</number>
</property>
<property name="leftMargin">
<number>9</number>
</property>
<property name="topMargin">
<number>9</number>
</property>
<property name="rightMargin">
<number>9</number>
</property>
<property name="bottomMargin">
<number>9</number>
</property>
<item>
<widget class="QTextEdit" name="logTextEdit">
<property name="font">
<font>
<family>Monospace</family>
</font>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="autoFormatting">
<set>QTextEdit::AutoNone</set>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout">
<property name="spacing">
<number>6</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>131</width>
<height>31</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="okButton">
<property name="text">
<string>OK</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>okButton</sender>
<signal>clicked()</signal>
<receiver>logDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>278</x>
<y>253</y>
</hint>
<hint type="destinationlabel">
<x>96</x>
<y>254</y>
</hint>
</hints>
</connection>
</connections>
</ui>
9 changes: 9 additions & 0 deletions avidemux_core/ADM_core/include/ADM_default.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>

#ifndef _WIN32 // needed for unlink
#include <unistd.h>
Expand All @@ -45,10 +46,18 @@ extern "C"
ADM_CORE6_EXPORT void ADM_warning2(const char *f,const char *st, ...) ;
ADM_CORE6_EXPORT void ADM_info2(const char *f,const char *st, ...) ;
ADM_CORE6_EXPORT void ADM_error2(const char *f,const char *st, ...) ;
ADM_CORE6_EXPORT void ADM_debugInit();
ADM_CORE6_EXPORT void ADM_debugFree();
ADM_CORE6_EXPORT const char * ADM_debugLogRead(void);
ADM_CORE6_EXPORT void ADM_setVerboseLog(bool verbose);
ADM_CORE6_EXPORT bool ADM_verboseLogging(void);

#define ADM_warning(a,...) ADM_warning2(__FUNCTION__,a, ##__VA_ARGS__)
#define ADM_info(a,...) ADM_info2(__FUNCTION__,a, ##__VA_ARGS__)
#define ADM_error(a,...) ADM_error2(__FUNCTION__,a, ##__VA_ARGS__)
#define ADM_verboseWarning(a,...) {if (ADM_verboseLogging()) ADM_warning2(__FUNCTION__,a, ##__VA_ARGS__);}
#define ADM_verboseInfo(a,...) {if (ADM_verboseLogging()) ADM_info2(__FUNCTION__,a, ##__VA_ARGS__);}
#define ADM_verboseError(a,...) {if (ADM_verboseLogging()) ADM_error2(__FUNCTION__,a, ##__VA_ARGS__);}

ADM_CORE6_EXPORT const char *ADM_translate(const char *domain, const char *stringToTranslate);

Expand Down
Loading