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: mbed
Diff: Logger.h
- Revision:
- 0:9e26d3c8b2b1
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Logger.h Thu Feb 12 13:49:58 2015 +0000
@@ -0,0 +1,50 @@
+#pragma once
+
+#include "mbed.h"
+#include <string>
+#include <ctime>
+
+LocalFileSystem local("local");
+
+class Logger
+{
+public:
+ Logger()
+ {
+ oppstartstid = time(NULL);
+ logFile = fopen("/local/Logg.txt", "a");
+ if (logFile == NULL) { // vis en error
+ return;
+ }
+ fprintf(logFile, "\nStarting up system\n");
+ fflush(logFile);
+ wait(0.1);
+ fclose(logFile);
+ }
+ ~Logger() {
+ if (logFile)
+ fclose(logFile);
+ }
+
+ void Logg(const std::string &melding)
+ {
+ logFile = fopen("/local/Logg.txt", "a");
+ if (logFile == NULL) { // vis en error
+ return;
+ }
+ int tid = time(NULL) - oppstartstid;
+ fprintf(logFile, "Tid: %d\t\t", tid);
+ fputs(melding.c_str(),logFile);
+ fputs("\n", logFile);
+ fflush(logFile);
+ wait(0.1);
+ fclose(logFile);
+ return;
+ }
+
+
+private:
+ FILE * logFile;
+ time_t oppstartstid;
+};
+