Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of LogUtil by
Revision 1:491d2a7f4207, committed 2013-03-29
- Comitter:
- sam_grove
- Date:
- Fri Mar 29 20:02:18 2013 +0000
- Parent:
- 0:3054bbdace4c
- Child:
- 2:c54746c59ba4
- Commit message:
- Updated documentation and added exit to error
Changed in this revision
| LogUtil.cpp | Show annotated file Show diff for this revision Revisions of this file |
| LogUtil.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/LogUtil.cpp Fri Mar 29 17:36:50 2013 +0000
+++ b/LogUtil.cpp Fri Mar 29 20:02:18 2013 +0000
@@ -3,7 +3,7 @@
* @brief Utility to log messages during runtime
* @author sam grove
* @version 1.0
- * @see http://www.drdobbs.com/cpp/a-lightweight-logger-for-c/240147505?pgno=2
+ * @see http://www.drdobbs.com/cpp/a-lightweight-logger-for-c/240147505
*
* Copyright (c) 2013
*
@@ -27,6 +27,9 @@
{
Serial debug(USBTX, USBRX);
debug.baud(921600);
+ debug.printf("\033[2J"); // clear the terminal
+ debug.printf("\033[1;1H");// and set the cursor to home
+ wait(0.5f);
return;
}
--- a/LogUtil.h Fri Mar 29 17:36:50 2013 +0000
+++ b/LogUtil.h Fri Mar 29 20:02:18 2013 +0000
@@ -3,7 +3,7 @@
* @brief Utility to log messages during runtime
* @author sam grove
* @version 1.0
- * @see http://www.drdobbs.com/cpp/a-lightweight-logger-for-c/240147505?pgno=2
+ * @see http://www.drdobbs.com/cpp/a-lightweight-logger-for-c/240147505
*
* Copyright (c) 2013
*
@@ -32,7 +32,9 @@
fprintf(STREAM, ##__VA_ARGS__)
#define ERROR(...) \
fprintf(STREAM, "ERROR: %s L#%d ", __PRETTY_FUNCTION__, __LINE__); \
- fprintf(STREAM, ##__VA_ARGS__)
+ fprintf(STREAM, ##__VA_ARGS__); \
+ fflush(STREAM); \
+ exit(1)
/** Using the LogUtil class
*
@@ -41,25 +43,22 @@
* #include "mbed.h"
* #include "LogUtil.h"
*
- * LogUtil log;
+ * LogUtil logger;
*
* int main()
* {
* LOG("This is a log\n");
* WARN("This is a warning\n");
- * ERROR("This is an error\n");
*
- * for(int i=0; i<10; ++i) {
+ * for(int i=0; i<3; ++i) {
* LOG("Log message #%d\n", i);
* }
*
- * for(int i=0; i<10; ++i) {
+ * for(int i=0; i<3; ++i) {
* WARN("Warn message #%d\n", i);
* }
*
- * for(int i=0; i<10; ++i) {
- * ERROR("Error message #%d\n", i);
- * }
+ * ERROR("This is an error\n");
* }
* @endcode
*/
