Improve logging when opening a MIDI file

* Flush debugging logs immediately after each message
* Print "Opening song" before the related log messages
This commit is contained in:
Martchus 2023-12-26 22:03:49 +01:00
parent 8b720e66e0
commit b3737c04c2
3 changed files with 3 additions and 2 deletions

View File

@ -93,6 +93,7 @@ void CMidiTrack::ppDebugTrack(int level, const char *msg, ...)
vfprintf(stdout, msg, ap);
va_end(ap);
fputc('\n', stdout);
fflush(stdout);
}
dword_t CMidiTrack::readVarLen()

View File

@ -59,9 +59,9 @@ void CSong::loadSong(const QString & filename)
#endif
auto logLevelOk = false;
auto logLevel = qEnvironmentVariableIntValue(PROJECT_VARNAME_UPPER "_MIDI_FILE_LOG_LEVEL", &logLevelOk);
ppLogInfo("Opening song %s", fn.toLocal8Bit().data());
m_midiFile->setLogLevel(logLevelOk ? logLevel : 3);
m_midiFile->openMidiFile(std::string(fn.toLocal8Bit().data()));
ppLogInfo("Opening song %s", fn.toLocal8Bit().data());
transpose(0);
midiFileInfo();
m_midiFile->setLogLevel(99);

View File

@ -71,7 +71,7 @@ static void openLogFile() {
static void flushLogs()
{
if (logInfoFile != stdout && logsOpened)
if (logInfoFile && logsOpened)
{
fflush(logInfoFile);
// logErrorFile is the same as logInfoFile