-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use defensive logging techniques to improve usability and perceived stability. Worked with Josh to create a new family of logging macros for validating assumptions and preconditions without aborting the application. We have provided a diagnostics output area where users can obtain logs of internal editor issues when they occur within RadialGM and report them back to us.
- Loading branch information
1 parent
a149246
commit 89a82ff
Showing
12 changed files
with
207 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#ifndef LOGGER_H | ||
#define LOGGER_H | ||
|
||
#include <QDebug> | ||
#include <QtGlobal> | ||
|
||
class LogAndReturn { | ||
QDebug logger; | ||
|
||
public: | ||
LogAndReturn(QtMsgType msgType) : logger(msgType) {} | ||
LogAndReturn(const QDebug&& log) : logger(log) {} | ||
|
||
template <typename T> | ||
LogAndReturn& operator<<(T t) { | ||
logger << t; | ||
return *this; | ||
} | ||
struct Void { | ||
void operator,(const LogAndReturn& /*log*/) {} | ||
}; | ||
}; | ||
template <typename T> | ||
T operator,(T x, const LogAndReturn&) { | ||
return x; | ||
} | ||
|
||
// check and log the condition, return value when failed | ||
#define R_EXPECT(cond, ret) \ | ||
if (cond) { \ | ||
} else \ | ||
return ret, LogAndReturn(qWarning()) << "Check `" #cond "` failed." | ||
|
||
// check and log the condition, return void when failed | ||
#define R_EXPECT_V(cond) \ | ||
if (cond) { \ | ||
} else \ | ||
return LogAndReturn::Void(), LogAndReturn(qWarning()) << "Check `" #cond "` failed." | ||
|
||
// check and log the condition, but continue on failure | ||
#define R_ASSESS(cond) \ | ||
if (cond) { \ | ||
} else \ | ||
LogAndReturn(qWarning()) << "Check `" #cond "` failed." | ||
|
||
#endif // LOGGER_H |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters