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

Use QtLogging Message Pattern to replace MYNAME #1367

Merged
merged 54 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
f602468
use qlogging message pattern to replace MYNAME.
tsteven4 Oct 31, 2024
25a1a2f
first cut at removal of MYNAME.
tsteven4 Nov 1, 2024
9b5e265
add message type support
tsteven4 Nov 1, 2024
82b2425
introduce DebugLog class to transform printf ...
tsteven4 Nov 2, 2024
ed3ebaf
handle debug printing in garmin_gpi
tsteven4 Nov 2, 2024
382323d
use DebugLog with lowranceusr
tsteven4 Nov 2, 2024
106cdd3
use DebugLog in dg100
tsteven4 Nov 2, 2024
5ad771c
fix logging in garmin_txt
tsteven4 Nov 2, 2024
c489fe8
use DebugLog in exif
tsteven4 Nov 2, 2024
9755dbf
use logging for validate.
tsteven4 Nov 2, 2024
e18297b
fix includes
tsteven4 Nov 2, 2024
5c55422
use DebugLog in igc
tsteven4 Nov 2, 2024
c6582ff
use logging in kml
tsteven4 Nov 2, 2024
9a0cb33
use logging in garmin
tsteven4 Nov 2, 2024
3fb1f2e
use DebugLog in mtk.
tsteven4 Nov 2, 2024
991c11d
use DebugLog in tpo
tsteven4 Nov 2, 2024
919b02f
use logging in trackfilter
tsteven4 Nov 2, 2024
3638506
use DebugLog for v900
tsteven4 Nov 2, 2024
2fd0755
use DebugLog in skytraq
tsteven4 Nov 2, 2024
74479cb
use logging with nmea.
tsteven4 Nov 2, 2024
86275ba
fix dg100, update references, chop extra newlines.
tsteven4 Nov 2, 2024
cfc576c
appease MSVC C2131
tsteven4 Nov 2, 2024
234ebec
fix garmin_gpi address debug messages.
tsteven4 Nov 2, 2024
ffc87eb
fix comparison with testo -D 9 igc format
tsteven4 Nov 2, 2024
030c9c6
match globalsat sport ws debug messages
tsteven4 Nov 2, 2024
cb91706
match ws on fatal()
tsteven4 Nov 2, 2024
c151cd3
update references for option->stderr and
tsteven4 Nov 2, 2024
7e641aa
Merge branch 'master' into mynamebyebye
tsteven4 Nov 2, 2024
8b004f3
ws
tsteven4 Nov 2, 2024
a395e34
don't send empty string to QDebug.
tsteven4 Nov 2, 2024
2c4cfb3
drop another empty string from logging.
tsteven4 Nov 2, 2024
702197a
cleanup fatal, flush is done in message handler.
tsteven4 Nov 3, 2024
a7fa3fd
move conditional logging check earlier.
tsteven4 Nov 3, 2024
8cb7083
make member functions static
tsteven4 Nov 3, 2024
fbc6732
fix debug build.
tsteven4 Nov 3, 2024
f892a57
eliminate some QString<->QByteArray round trips.
tsteven4 Nov 3, 2024
a9b76e8
purse QStrings from fatal routines.
tsteven4 Nov 3, 2024
f148a14
rename logging functions for easier script editing.
tsteven4 Nov 4, 2024
b3594ff
add macro gbLogCStr for use with our logging.
tsteven4 Nov 4, 2024
d7b0b77
change logging back to using QStrings.
tsteven4 Nov 4, 2024
084abed
manual rename logging routines in windows only files.
tsteven4 Nov 4, 2024
76fa055
use global gbLog instead of DebugLog instances.
tsteven4 Nov 5, 2024
d20c66f
convert all gb printflike logging to accumulate lines.
tsteven4 Nov 5, 2024
c9ffce8
use gbDebug instead of gbLog. They are equivalent.
tsteven4 Nov 5, 2024
4e5655a
remove unecessary choping.
tsteven4 Nov 5, 2024
e909bad
fix getLogString, flush fatal log stream.
tsteven4 Nov 5, 2024
ae01464
terminate gbFatal format strings with a newline.
tsteven4 Nov 5, 2024
db294ec
terminate gbWarning format strings.
tsteven4 Nov 5, 2024
011f136
switch to our own MessageHandler for legacy logging.
tsteven4 Nov 6, 2024
9a11fcc
rename LegacyLog components.
tsteven4 Nov 6, 2024
400dcfb
update fatal.cc includes
tsteven4 Nov 6, 2024
ddbe287
Merge branch 'master' into mynamebyebye
tsteven4 Nov 6, 2024
783ce61
use same stream in waypt_status_disp & termination in waypt_disp_sess…
tsteven4 Nov 7, 2024
a48e6f0
review catches, mostly in comments or dead code.
tsteven4 Nov 7, 2024
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
23 changes: 11 additions & 12 deletions arcdist.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include "arcdist.h"

#include <cmath> // for round
#include <cstdio> // for printf, sscanf
#include <cstdio> // for sscanf
#include <tuple> // for tie, tuple

#include <QByteArray> // for QByteArray
Expand All @@ -37,7 +37,6 @@


#if FILTERS_ENABLED
#define MYNAME "Arc filter"

#define BADVAL 999999

Expand Down Expand Up @@ -66,10 +65,10 @@ void ArcDistanceFilter::arcdist_arc_disp_wpt_cb(const Waypoint* arcpt2)
frac = 1.0;
} else {
if (waypointp == nullptr) {
fatal(FatalMsg() << "Internal error. Attempt to project through a waypoint that doesn't exist");
gbFatal(FatalMsg() << "Internal error. Attempt to project through a waypoint that doesn't exist");
}
if (arcpt1 == nullptr) {
fatal(FatalMsg() << "Internal error: Attempt to project waypoint without predecessor");
gbFatal(FatalMsg() << "Internal error: Attempt to project waypoint without predecessor");
}

std::tie(dist, prjpos, frac) = linedistprj(arcpt1->position(),
Expand Down Expand Up @@ -112,7 +111,7 @@ void ArcDistanceFilter::process()
QString line;

gpsbabel::TextStream stream;
stream.open(arcfileopt, QIODevice::ReadOnly, MYNAME);
stream.open(arcfileopt, QIODevice::ReadOnly);

auto* arcpt1 = new Waypoint;
auto* arcpt2 = new Waypoint;
Expand All @@ -134,7 +133,7 @@ void ArcDistanceFilter::process()
int argsfound = sscanf(CSTR(line), "%lf %lf", &arcpt2->latitude, &arcpt2->longitude);

if ((argsfound != 2) && (line.trimmed().size() > 0)) {
warning(MYNAME ": Warning: Arc file contains unusable vertex on line %d.\n", fileline);
gbWarning("Warning: Arc file contains unusable vertex on line %d.\n", fileline);
} else {
Waypoint* arcpttmp = arcpt1;
arcdist_arc_disp_wpt_cb(arcpt2);
Expand Down Expand Up @@ -190,16 +189,16 @@ void ArcDistanceFilter::process()
}
}
if (global_opts.debug_level >= 1) {
warning("Including waypoint %s at dist:%f lat:%f lon:%f\n",
qPrintable(wp->shortname), ed->distance, wp->latitude, wp->longitude);
gbWarning("Including waypoint %s at dist:%f lat:%f lon:%f\n",
gbLogCStr(wp->shortname), ed->distance, wp->latitude, wp->longitude);
}
}
delete ed;
}
}
del_marked_wpts();
if (global_opts.verbose_status > 0) {
printf(MYNAME "-arc: %u waypoint(s) removed.\n", removed);
gbInfo("%u waypoint(s) removed.\n", removed);
}
}

Expand All @@ -208,14 +207,14 @@ void ArcDistanceFilter::init()
if ((!arcfileopt && !rteopt && !trkopt) ||
(arcfileopt && (rteopt || trkopt)) ||
(rteopt && trkopt)) {
fatal(MYNAME ": Incompatible or incomplete option values!\n");
gbFatal("Incompatible or incomplete option values!\n");
}

pos_dist = 0.0;

if (distopt) {
if (parse_distance(distopt, &pos_dist, kMetersPerMile, MYNAME) == 0) {
fatal(MYNAME ": No distance specified with distance option.\n");
if (parse_distance(distopt, &pos_dist, kMetersPerMile) == 0) {
gbFatal("No distance specified with distance option.\n");
}
}
}
Expand Down
2 changes: 0 additions & 2 deletions bend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@
#include "grtcirc.h" // for RAD, heading_true_degrees, gcdist, linepart, radtometers, DEG


#define MYNAME "bend"

#if FILTERS_ENABLED

void BendFilter::init()
Expand Down
10 changes: 4 additions & 6 deletions csv_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@
#include "src/core/logging.h" // for Warning


#define MYNAME "CSV_UTIL"

/*********************************************************************/
/* csv_stringclean() - remove any unwanted characters from string. */
/* returns copy of string. */
Expand Down Expand Up @@ -229,7 +227,7 @@ csv_linesplit(const QString& string, const QString& delimited_by,
}

if (enclosed) {
Warning() << MYNAME":" <<
Warning() <<
"Warning- Unbalanced Field Enclosures" <<
enclosed_in <<
"on line" <<
Expand Down Expand Up @@ -528,7 +526,7 @@ dec_to_human(const char* format, const char* dirs, double val)
case 'x':
case 'X':
if (index>2) {
fatal(MYNAME ": too many format specifiers\n");
gbFatal("too many format specifiers\n");
}
buff += QString::asprintf(subformat, intvals[index]);
index++;
Expand All @@ -539,7 +537,7 @@ dec_to_human(const char* format, const char* dirs, double val)
case 'g':
case 'G':
if (index>2) {
fatal(MYNAME ": too many format specifiers\n");
gbFatal("too many format specifiers\n");
}
buff += QString::asprintf(subformat, dblvals[index]);
index++;
Expand All @@ -548,7 +546,7 @@ dec_to_human(const char* format, const char* dirs, double val)
buff += subformat;
break;
default:
fatal(MYNAME ": invalid format specifier\n");
gbFatal("invalid format specifier\n");
break;

}
Expand Down
27 changes: 17 additions & 10 deletions defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
#include "src/core/datetime.h" // for DateTime


#define gbLogCStr(qstr) qUtf8Printable(qstr)
#define CSTR(qstr) ((qstr).toUtf8().constData())
#define CSTRc(qstr) ((qstr).toLatin1().constData())

Expand Down Expand Up @@ -571,7 +572,9 @@ WaypointList::waypt_disp_session(const session_t* se, T cb)
}
}
if (global_opts.verbose_status) {
fprintf(stdout, "\r\n");
// Terminate the progress line from waypt_status_disp.
fprintf(stderr, "\n");
fflush(stderr);
}
}

Expand Down Expand Up @@ -907,17 +910,21 @@ enum ff_cap {
#define FF_CAP_RW_WPT \
{ (ff_cap) (ff_cap_read | ff_cap_write), ff_cap_none, ff_cap_none}

[[noreturn]] void fatal(QDebug& msginstance);
// cppcheck 2.10.3 fails to assign noreturn attribute to fatal if
[[noreturn]] void gbFatal(QDebug& msginstance);
// cppcheck 2.10.3 fails to assign noreturn attribute to gbFatal if
// the noreturn attribute is listed before the gnu::format attribute.
// A PR to resolve this is https://github.com/danmar/cppcheck/pull/4971,
// but cppcheck works if the noreturn attribute follows the gnu::format
// attribute.
// This can have a large effect on codacy issues from cppcheck
// nullPointerRedundantCheck, nullPointerArithmeticRedundantCheck,
// negativeIndex, arrayIndexOutOfBoundsCond.
[[gnu::format(printf, 1, 2)]] [[noreturn]] void fatal(const char* fmt, ...);
[[gnu::format(printf, 1, 2)]] void warning(const char* fmt, ...);
[[gnu::format(printf, 1, 2)]] [[noreturn]] void gbFatal(const char* fmt, ...);
[[gnu::format(printf, 1, 2)]] void gbWarning(const char* fmt, ...);
[[gnu::format(printf, 1, 2)]] void gbInfo(const char* fmt, ...);
[[gnu::format(printf, 1, 2)]] void gbDebug(const char* fmt, ...);

void gbVLegacyLog(QtMsgType type, const char* fmt, va_list args1);

void printposn(double c, bool is_lat);

Expand All @@ -927,7 +934,7 @@ void* xrealloc(void* p, size_t s);
void xfree(const void* mem);
char* xstrdup(const char* s);

FILE* xfopen(const QString& fname, const char* type, const QString& errtxt);
FILE* xfopen(const QString& fname, const char* type);

// Thin wrapper around fopen() that supports Unicode fname on all platforms.
FILE* ufopen(const QString& fname, const char* mode);
Expand Down Expand Up @@ -1028,11 +1035,11 @@ int xstrtoi(const char* str, char** str_end, int base);
int parse_integer(const QString& str, const QString& id, bool* ok = nullptr, QString* end = nullptr, int base = 10);
double parse_double(const QString& str, const QString& id, bool* ok = nullptr, QString* end = nullptr);
int parse_coordinates(const char* str, int datum, grid_type grid,
double* latitude, double* longitude, const char* module);
double* latitude, double* longitude);
int parse_coordinates(const QString& str, int datum, grid_type grid,
double* latitude, double* longitude, const char* module);
int parse_distance(const QString& str, double* val, double scale, const char* module);
int parse_speed(const QString& str, double* val, double scale, const char* module);
double* latitude, double* longitude);
int parse_distance(const QString& str, double* val, double scale);
int parse_speed(const QString& str, double* val, double scale);

/*
* Color helpers.
Expand Down
Loading