Skip to content

Commit

Permalink
fix dg100, update references, chop extra newlines.
Browse files Browse the repository at this point in the history
  • Loading branch information
tsteven4 committed Nov 2, 2024
1 parent 74479cb commit 86275ba
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 32 deletions.
2 changes: 1 addition & 1 deletion dg-100.cc
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ Dg100Format::dg100_log(const char* fmt, ...)
va_list ap;
va_start(ap, fmt);
if (global_opts.debug_level > 0) {
db.log(fmt, ap);
db.vlog(fmt, ap);
}
va_end(ap);
}
Expand Down
9 changes: 9 additions & 0 deletions fatal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ warning(const char* fmt, ...)
va_start(ap, fmt);
QString msg = QString::vasprintf(fmt, ap);
va_end(ap);
if (msg.endsWith('\n')) {
msg.chop(1);
}
qWarning().noquote() << msg;
}

Expand All @@ -70,6 +73,9 @@ info(const char* fmt, ...)
va_start(ap, fmt);
QString msg = QString::vasprintf(fmt, ap);
va_end(ap);
if (msg.endsWith('\n')) {
msg.chop(1);
}
qInfo().noquote() << msg;
}

Expand All @@ -80,6 +86,9 @@ debug(const char* fmt, ...)
va_start(ap, fmt);
QString msg = QString::vasprintf(fmt, ap);
va_end(ap);
if (msg.endsWith('\n')) {
msg.chop(1);
}
qDebug().noquote() << msg;
}

Expand Down
20 changes: 10 additions & 10 deletions main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

#include <QCoreApplication> // for QCoreApplication
#include <QDateTime> // for QDateTime
#include <QDebug> // for QDebug
#include <QElapsedTimer> // for QElapsedTimer
#include <QFile> // for QFile
#include <QIODevice> // for QIODevice::ReadOnly
Expand Down Expand Up @@ -55,7 +56,6 @@
#include "session.h" // for start_session, session_exit, session_init
#include "src/core/datetime.h" // for DateTime
#include "src/core/file.h" // for File
#include "src/core/logging.h" // for Warning
#include "src/core/usasciicodec.h" // for UsAsciiCodec
#include "vecs.h" // for Vecs

Expand Down Expand Up @@ -278,7 +278,7 @@ run_reader(Vecs::fmtinfo_t& ivecs, const QString& fname)
}
setMessagePattern();
if (global_opts.debug_level > 0) {
Warning().noquote() << QStringLiteral("reader %1 took %2 seconds.")
qDebug().noquote() << QStringLiteral("reader %1 took %2 seconds.")
.arg(ivecs.fmtname, QString::number(timer.elapsed()/1000.0, 'f', 3));
}
}
Expand Down Expand Up @@ -312,7 +312,7 @@ run_writer(Vecs::fmtinfo_t& ovecs, const QString& ofname)
}
setMessagePattern();
if (global_opts.debug_level > 0) {
Warning().noquote() << QStringLiteral("writer %1 took %2 seconds.")
qDebug().noquote() << QStringLiteral("writer %1 took %2 seconds.")
.arg(ovecs.fmtname, QString::number(timer.elapsed()/1000.0, 'f', 3));
}
}
Expand Down Expand Up @@ -499,7 +499,7 @@ run(const char* prog_name)
}
setMessagePattern();
if (global_opts.debug_level > 0) {
Warning().noquote() << QStringLiteral("filter %1 took %2 seconds.")
qDebug().noquote() << QStringLiteral("filter %1 took %2 seconds.")
.arg(filter.fltname, QString::number(timer.elapsed()/1000.0, 'f', 3));
}
} else {
Expand Down Expand Up @@ -777,7 +777,7 @@ main(int argc, char* argv[])
#endif

if constexpr (DEBUG_LOCALE) {
printf("Initial locale: %s\n",setlocale(LC_ALL, nullptr));
debug("Initial locale: %s\n",setlocale(LC_ALL, nullptr));
}

// Create a QCoreApplication object to handle application initialization.
Expand All @@ -794,29 +794,29 @@ main(int argc, char* argv[])
// as opposed to the initial default "C" locale.
// This was demonstrated with Qt5 on Mac OS X.
if constexpr (DEBUG_LOCALE) {
printf("Locale after initial setup: %s\n",setlocale(LC_ALL, nullptr));
debug("Locale after initial setup: %s\n",setlocale(LC_ALL, nullptr));
}
// As recommended in QCoreApplication reset the locale to the default.
// Note the documentation says to set LC_NUMERIC, but QCoreApplicationPrivate::initLocale()
// actually sets LC_ALL.
// Perhaps we should restore LC_ALL instead of only LC_NUMERIC.
if (strcmp(setlocale(LC_NUMERIC,nullptr), "C") != 0) {
if constexpr (DEBUG_LOCALE) {
printf("Resetting LC_NUMERIC\n");
debug("Resetting LC_NUMERIC\n");
}
setlocale(LC_NUMERIC,"C");
if constexpr (DEBUG_LOCALE) {
printf("LC_ALL: %s\n",setlocale(LC_ALL, nullptr));
debug("LC_ALL: %s\n",setlocale(LC_ALL, nullptr));
}
}
/* reset LC_TIME for strftime */
if (strcmp(setlocale(LC_TIME,nullptr), "C") != 0) {
if constexpr (DEBUG_LOCALE) {
printf("Resetting LC_TIME\n");
debug("Resetting LC_TIME\n");
}
setlocale(LC_TIME,"C");
if constexpr (DEBUG_LOCALE) {
printf("LC_ALL: %s\n",setlocale(LC_ALL, nullptr));
debug("LC_ALL: %s\n",setlocale(LC_ALL, nullptr));
}
}
qInstallMessageHandler(MessageHandler);
Expand Down
16 changes: 8 additions & 8 deletions reference/dg200erase.log
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
TX: Frame Start a0 a2 Payload_Len 0003 Cmd: getfileheader
RX: Start a0a2 Len 0005 Cmd: getfileheader
found 0 headers, nextheader=0
no further headers, aborting the loop
TX: Frame Start a0 a2 Payload_Len 0001 Cmd: getconfig
RX: Start a0a2 Len 002e Cmd: getconfig
TX: Frame Start a0 a2 Payload_Len 0003 Cmd: erase
RX: Start a0a2 Len 0005 Cmd: erase
dg-200-bin: TX: Frame Start a0 a2 Payload_Len 0003 Cmd: getfileheader
dg-200-bin: RX: Start a0a2 Len 0005 Cmd: getfileheader
dg-200-bin: found 0 headers, nextheader=0
dg-200-bin: no further headers, aborting the loop
dg-200-bin: TX: Frame Start a0 a2 Payload_Len 0001 Cmd: getconfig
dg-200-bin: RX: Start a0a2 Len 002e Cmd: getconfig
dg-200-bin: TX: Frame Start a0 a2 Payload_Len 0003 Cmd: erase
dg-200-bin: RX: Start a0a2 Len 0005 Cmd: erase
26 changes: 13 additions & 13 deletions reference/validate_debug.log
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@

Processing waypts
point ct: 2, waypt_count: 2

Processing routes
route 0 ct: 2, waypt_count: 2, segments 1
route head ct: 1, route_count: 1, total segment count: 1
total route point ct: 2, route_waypt_count: 2

Processing tracks
track 0 ct: 2, waypt_count: 2, segments 1
track head ct: 1, track_count: 1, total segment count: 1
total track point ct: 2, track_waypt_count: 2
validate:
validate: Processing waypts
validate: point ct: 2, waypt_count: 2
validate:
validate: Processing routes
validate: route 0 ct: 2, waypt_count: 2, segments 1
validate: route head ct: 1, route_count: 1, total segment count: 1
validate: total route point ct: 2, route_waypt_count: 2
validate:
validate: Processing tracks
validate: track 0 ct: 2, waypt_count: 2, segments 1
validate: track head ct: 1, track_count: 1, total segment count: 1
validate: total track point ct: 2, track_waypt_count: 2

0 comments on commit 86275ba

Please sign in to comment.