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.
Dependencies: C027_Support C12832 LM75B MMA7660 MbedSmartRest mbed-rtos mbed
Fork of MbedSmartRestMain by
Diff: logging/logging.cpp
- Revision:
- 72:c5709ae7b193
- Child:
- 77:f6717e4eccc4
diff -r 063c45e99578 -r c5709ae7b193 logging/logging.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/logging/logging.cpp Mon Feb 16 13:15:52 2015 +0000
@@ -0,0 +1,81 @@
+#include <cstdio>
+#include <cstdarg>
+#include "logging.h"
+using namespace std;
+
+
+aLogLevel _level = A_INFO; // Default log level is INFO.
+
+int _log(aLogLevel lvl, const char *fmt, va_list& vlist)
+{
+ if (_level <= lvl) {
+ int n = 0;
+ switch (lvl)
+ {
+ case A_DEBUG: n += printf("[DEBUG] "); break;
+ case A_WARNING: n += printf("[WARN] "); break;
+ case A_INFO: n += printf("[INFO] "); break;
+ case A_ERROR: n += printf("[ERROR] "); break;
+ case A_CRITICAL: n += printf("[CRITICAL] "); break;
+ default: n += printf("[UNKNOWN] "); break;
+ }
+ return n+vprintf(fmt, vlist);
+ } else {
+ return 0;
+ }
+}
+
+int aDebug(const char *fmt, ...)
+{
+ va_list vlist;
+ va_start(vlist, fmt);
+ int n = _log(A_DEBUG, fmt, vlist);
+ va_end(vlist);
+ return n;
+}
+
+int aCritical(const char *fmt, ...)
+{
+ va_list vlist;
+ va_start(vlist, fmt);
+ int n = _log(A_CRITICAL, fmt, vlist);
+ va_end(vlist);
+ return n;
+}
+
+int aError(const char *fmt, ...)
+{
+ va_list vlist;
+ va_start(vlist, fmt);
+ int n = _log(A_ERROR, fmt, vlist);
+ va_end(vlist);
+ return n;
+}
+
+int aInfo(const char *fmt, ...)
+{
+ va_list vlist;
+ va_start(vlist, fmt);
+ int n = _log(A_INFO, fmt, vlist);
+ va_end(vlist);
+ return n;
+}
+
+int aWarning(const char *fmt, ...)
+{
+ va_list vlist;
+ va_start(vlist, fmt);
+ int n = _log(A_WARNING, fmt, vlist);
+ va_end(vlist);
+ return n;
+}
+
+aLogLevel getLevel()
+{
+ return _level;
+}
+
+void setLevel(aLogLevel lvl)
+{
+ _level = lvl;
+}
