Skip to content

Commit

Permalink
opt:write the log according to the configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoyifang committed Jan 23, 2025
1 parent 5a2ea0e commit 62fc3f6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ QMutex logMutex;

void gdMessageHandler( QtMsgType type, const QMessageLogContext & context, const QString & mess )
{
if(GlobalBroadcaster::instance()->getPreference()==nullptr||!GlobalBroadcaster::instance()->getPreference()->enableApplicationLog)
{
return;
}
QString strTime = QDateTime::currentDateTime().toString( "MM-dd hh:mm:ss" );
QString message = QString( "%1 %2\r\n" ).arg( strTime, mess );

Expand Down Expand Up @@ -522,7 +526,6 @@ int main( int argc, char ** argv )

cfg.resetState = gdcl.resetState;

if ( gdcl.needLogFile() ) {
// Open log file
logFilePtr->setFileName( Config::getConfigDir() + "gd_log.txt" );
logFilePtr->remove();
Expand All @@ -535,7 +538,6 @@ int main( int argc, char ** argv )

// Install message handler
qInstallMessageHandler( gdMessageHandler );
}

// Reload translations for user selected locale is nesessary
QTranslator qtTranslator;
Expand Down

0 comments on commit 62fc3f6

Please sign in to comment.