-
Notifications
You must be signed in to change notification settings - Fork 127
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
Conversation
The bulk edit changed printf statements which don't go through the Qt Logging system. These need adjustment to use the message pattern. |
There is another issue with newlines. Traditionally we don't implicitly insert them, e.g. with warning(), but at the same time we expect qDebug() << ... to insert them. gdb in particular expects only explicitly inserted newlines in the DBG printf statements which we want to capture in logging. |
and massage some logging with internal newlines.
style character output into lines suitable for logging.
Another issue is the use of printf without a trailing newline. These are sometimes used to accumulate character output which will eventually be terminated with a newline. These newline-less printf statements cannot be logged directly, instead we must transform the character output into lines and log those. DebugLog is a new class to do that, demonstrated in globalsat_sport. |
including removal of POSIX printf arguement reordring
and direct vecs debug output to debug msg.
gbser and jeeps logging aren't included. |
Besides an efficiency hit any variadic argument strings passed to these routines should already be in local8Bit.
thanks clion.
All but one line was changed by sed (ok, the sed script took a few tries.) This allows us to change the encoding passed to our printf style logging routines in one place.
QtMessageHandler operates on QStrings.
Since we flush this isn't necessary, but let's be consistent.
We don't delay logging until we have a complete line, instead we output any bits as we go. We only format the log message if the last output for the first message or if the last output character was a newline.
Making allowances for missing/alternate MYNAME content, the log of testo with "-D 9" added to gpsbabel and the auxiliary functions disabled (*compare*, *check) we have only a few mis-compares (out of 1,251,735 lines). These are all related to the alternative representation of the g conversion specifier. The dropped trailing zeros seem to be a bug in QString::vasprintf. The sign of nan may be implementation defined. This seem unimportant to me.
|
The Qt Logging system is line based with implied newlines, while our traditional logging is printf based with explicit newlines. Sometimes we use multiple printf commands to assemble a line of log output. Another wrinkle is live status like waypt_status_disp with it's '\r' characters and mtk_logger with it's erase wheel '\b' character and mtk_read's Reading status update with '\b's. waypt_status_disp can be exercised with a modified dg100.test, but exercising the above portions of mtk requires a device. To deal with this I created a LegacyLogMessageHandler that we use with our traditional printf based logging. We use the Qt defaultMessageHandler for qDebug, qInfo, qWarning, ... and our src/core/logging based messages. Our legacy handler only formats a message with qFormatLogMessage (which inserts the "id: ", the replacement for MYNAME) on new log lines and outputs any messages regardless of newline content immediately. The defaultMessageHandler provide by Qt always formats a message with qFormatLogMessage and always uses an implied newline. |
Our legacy logger is currently implemented with QString::vasprintf, as is Qt printf style logging. If PIGS_FLY we can switch back to character string conversion. QString::vasprintf expects utf-8 encoded format and character strings arguments, while xvasprintf would want local8Bit encoding. The encoding is switchable be redefining gbLogCStr |
The "[id]: " message insertion is set up by setMessagePattern in main. As main runs formats and filters it updates the message pattern. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow! What a slog.
When I first started kicking around the idea of moving to c++ and having formats a s classes, MYNAME was one of the justifications for doign so. I'm happy you sent this to the grave it deserves.
Thanx!
…ion. stderr is a text stream which should translate '\n' -> '\r\n' on windows automatically.
One thing not converted is printf usage in gbser* or jeeps. |
All the action is in main.cc and fatal.cc. The other 78 files are deletions of MYNAME and descendants. The bulk of the changes were first done by the following script, the remainder by hand.