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.
Diff: ICE-Application/src/add-ons/ICELog/ICELog.cpp
- Revision:
- 0:61364762ee0e
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/ICE-Application/src/add-ons/ICELog/ICELog.cpp Tue Jan 24 19:05:33 2017 +0000
@@ -0,0 +1,63 @@
+#include "mbed.h"
+#include <stdarg.h>
+#include "ICELog.h"
+
+//using namespace mts;
+
+int ICELog::currentLevel = ICELog::WARNING_LEVEL;
+
+const char* ICELog::NONE_LABEL = "NONE";
+const char* ICELog::FATAL_LABEL = "FATAL";
+const char* ICELog::ERROR_LABEL = "ERROR";
+const char* ICELog::WARNING_LABEL = "WARNING";
+const char* ICELog::INFO_LABEL = "INFO";
+const char* ICELog::DEBUG_LABEL = "DEBUG";
+const char* ICELog::TRACE_LABEL = "TRACE";
+
+void ICELog::printMessage(int level, const char* format, ...) {
+ if (printable(level)) {
+ va_list argptr;
+ va_start(argptr, format);
+ vprintf(format, argptr);
+ va_end(argptr);
+ }
+}
+
+bool ICELog::printable(int level) {
+ return level <= currentLevel;
+}
+
+void ICELog::setLogLevel(int level) {
+ if (level < NONE_LEVEL)
+ currentLevel = NONE_LEVEL;
+ else if (level > TRACE_LEVEL)
+ currentLevel = TRACE_LEVEL;
+ else
+ currentLevel = level;
+}
+
+int ICELog::getLogLevel() {
+ return currentLevel;
+}
+
+const char* ICELog::getLogLevelString() {
+ switch (currentLevel) {
+ case NONE_LEVEL:
+ return NONE_LABEL;
+ case FATAL_LEVEL:
+ return FATAL_LABEL;
+ case ERROR_LEVEL:
+ return ERROR_LABEL;
+ case WARNING_LEVEL:
+ return WARNING_LABEL;
+ case INFO_LEVEL:
+ return INFO_LABEL;
+ case DEBUG_LEVEL:
+ return DEBUG_LABEL;
+ case TRACE_LEVEL:
+ return TRACE_LABEL;
+ default:
+ return "unknown";
+ }
+}
+
\ No newline at end of file