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 0:3054bbdace4c, committed 2013-03-29
- Comitter:
- sam_grove
- Date:
- Fri Mar 29 17:36:50 2013 +0000
- Child:
- 1:491d2a7f4207
- Commit message:
- Starting point for unified logging. Will be updated to redirect so it can be used during run time or in the field.
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 |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/LogUtil.cpp Fri Mar 29 17:36:50 2013 +0000
@@ -0,0 +1,34 @@
+/**
+ * @file LogUtil.cpp
+ * @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
+ *
+ * Copyright (c) 2013
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+ #include "LogUtil.h"
+ #include "mbed.h"
+
+ LogUtil::LogUtil()
+ {
+ Serial debug(USBTX, USBRX);
+ debug.baud(921600);
+
+ return;
+ }
+
+
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/LogUtil.h Fri Mar 29 17:36:50 2013 +0000
@@ -0,0 +1,84 @@
+/**
+ * @file LogUtil.h
+ * @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
+ *
+ * Copyright (c) 2013
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef LOGUTIL_H
+#define LOGUTIL_H
+
+#define STREAM stdout
+#define LOG(...) \
+ fprintf(STREAM, "LOG: %s L#%d ", __PRETTY_FUNCTION__, __LINE__); \
+ fprintf(STREAM, ##__VA_ARGS__)
+#define WARN(...) \
+ fprintf(STREAM, "WARN: %s L#%d ", __PRETTY_FUNCTION__, __LINE__); \
+ fprintf(STREAM, ##__VA_ARGS__)
+#define ERROR(...) \
+ fprintf(STREAM, "ERROR: %s L#%d ", __PRETTY_FUNCTION__, __LINE__); \
+ fprintf(STREAM, ##__VA_ARGS__)
+
+/** Using the LogUtil class
+ *
+ * Example:
+ * @code
+ * #include "mbed.h"
+ * #include "LogUtil.h"
+ *
+ * LogUtil log;
+ *
+ * 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) {
+ * LOG("Log message #%d\n", i);
+ * }
+ *
+ * for(int i=0; i<10; ++i) {
+ * WARN("Warn message #%d\n", i);
+ * }
+ *
+ * for(int i=0; i<10; ++i) {
+ * ERROR("Error message #%d\n", i);
+ * }
+ * }
+ * @endcode
+ */
+
+/**
+ * @class LogUtil
+ * @brief Different ways to log messages having a standard interface
+ */
+class LogUtil
+{
+public:
+
+ /** Construct the LogUtil class and configure
+ */
+ LogUtil();
+
+};
+
+
+#endif
+
+
