Skip to content

Commit

Permalink
Partially revert "Enable application log" to "Log to file"
Browse files Browse the repository at this point in the history
  • Loading branch information
shenlebantongying committed Feb 2, 2025
1 parent 057380b commit 284a559
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 17 deletions.
23 changes: 7 additions & 16 deletions src/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,6 @@ struct GDOptions
return popupGroupName;
}

inline bool needLogFile() const
{
return logFile;
}

inline bool needTranslateWord() const
{
return !word.isEmpty();
Expand Down Expand Up @@ -204,7 +199,7 @@ void processCommandLine( QCoreApplication * app, GDOptions * result )

QCommandLineOption logFileOption( QStringList() << "l"
<< "log-to-file",
QObject::tr( "Save debug messages to gd_log.txt in the config folder." ) );
QObject::tr( "Save debug messages to gd_log.txt in the config folder" ) + '.' );

QCommandLineOption resetState( QStringList() << "r"
<< "reset-window-state",
Expand Down Expand Up @@ -492,9 +487,6 @@ int main( int argc, char ** argv )
for ( ;; ) {
try {
cfg = Config::load();

//enabled through command line or preference
gdcl.logFile = gdcl.logFile || cfg.preferences.enableApplicationLog;
}
catch ( Config::exError & ) {
QMessageBox mb(
Expand Down Expand Up @@ -526,13 +518,12 @@ int main( int argc, char ** argv )

cfg.resetState = gdcl.resetState;

// Open log file
logFilePtr->setFileName( Config::getConfigDir() + "gd_log.txt" );
logFilePtr->open( QFile::WriteOnly );


// Install message handler
qInstallMessageHandler( gdMessageHandler );
// Log to file enabled through command line or preference
if ( gdcl.logFile || cfg.preferences.enableApplicationLog ) {
logFilePtr->setFileName( Config::getConfigDir() + "gd_log.txt" );
logFilePtr->open( QFile::WriteOnly );
qInstallMessageHandler( gdMessageHandler );
}

// Reload translations for user selected locale is nesessary
QTranslator qtTranslator;
Expand Down
2 changes: 1 addition & 1 deletion src/ui/preferences.ui
Original file line number Diff line number Diff line change
Expand Up @@ -1938,7 +1938,7 @@ from Stardict, Babylon and GLS dictionaries</string>
<item>
<widget class="QCheckBox" name="enableApplicationLog">
<property name="text">
<string>Enable application log</string>
<string>Save debug messages to gd_log.txt in the config folder</string>
</property>
</widget>
</item>
Expand Down

0 comments on commit 284a559

Please sign in to comment.