Sensor with Web Server
Dependencies: EthernetInterface mbed-rpc mbed-rtos mbed
DebugTrace.h@0:c385e589a779, 2014-04-08 (annotated)
- Committer:
- afilipem
- Date:
- Tue Apr 08 12:13:32 2014 +0000
- Revision:
- 0:c385e589a779
1 version;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
afilipem | 0:c385e589a779 | 1 | /* |
afilipem | 0:c385e589a779 | 2 | * DebugTrace. Allows dumping debug messages/values to serial or |
afilipem | 0:c385e589a779 | 3 | * to file. |
afilipem | 0:c385e589a779 | 4 | * |
afilipem | 0:c385e589a779 | 5 | * Copyright (C) <2009> Petras Saduikis <petras@petras.co.uk> |
afilipem | 0:c385e589a779 | 6 | * |
afilipem | 0:c385e589a779 | 7 | * This file is part of DebugTrace. |
afilipem | 0:c385e589a779 | 8 | * |
afilipem | 0:c385e589a779 | 9 | * DebugTrace is free software: you can redistribute it and/or modify |
afilipem | 0:c385e589a779 | 10 | * it under the terms of the GNU General Public License as published by |
afilipem | 0:c385e589a779 | 11 | * the Free Software Foundation, either version 3 of the License, or |
afilipem | 0:c385e589a779 | 12 | * (at your option) any later version. |
afilipem | 0:c385e589a779 | 13 | * |
afilipem | 0:c385e589a779 | 14 | * DebugTrace is distributed in the hope that it will be useful, |
afilipem | 0:c385e589a779 | 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
afilipem | 0:c385e589a779 | 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
afilipem | 0:c385e589a779 | 17 | * GNU General Public License for more details. |
afilipem | 0:c385e589a779 | 18 | * |
afilipem | 0:c385e589a779 | 19 | * You should have received a copy of the GNU General Public License |
afilipem | 0:c385e589a779 | 20 | * along with DebugTrace. If not, see <http://www.gnu.org/licenses/>. |
afilipem | 0:c385e589a779 | 21 | */ |
afilipem | 0:c385e589a779 | 22 | |
afilipem | 0:c385e589a779 | 23 | #ifndef SNATCH59_DEBUGTRACE_H |
afilipem | 0:c385e589a779 | 24 | #define SNATCH59_DEBUGTRACE_H |
afilipem | 0:c385e589a779 | 25 | |
afilipem | 0:c385e589a779 | 26 | enum eLog {OFF, ON}; |
afilipem | 0:c385e589a779 | 27 | enum eLogTarget {TO_SERIAL, TO_FILE}; |
afilipem | 0:c385e589a779 | 28 | |
afilipem | 0:c385e589a779 | 29 | class DebugTrace |
afilipem | 0:c385e589a779 | 30 | { |
afilipem | 0:c385e589a779 | 31 | public: |
afilipem | 0:c385e589a779 | 32 | DebugTrace(eLog on, eLogTarget mode, const char* fileName = "log.txt", const int maxSize = 1024); |
afilipem | 0:c385e589a779 | 33 | ~DebugTrace(); |
afilipem | 0:c385e589a779 | 34 | |
afilipem | 0:c385e589a779 | 35 | void clear(); |
afilipem | 0:c385e589a779 | 36 | void traceOut(const char* fmt, ...); |
afilipem | 0:c385e589a779 | 37 | |
afilipem | 0:c385e589a779 | 38 | private: |
afilipem | 0:c385e589a779 | 39 | eLog enabled; |
afilipem | 0:c385e589a779 | 40 | eLogTarget logMode; |
afilipem | 0:c385e589a779 | 41 | int maxFileSize; |
afilipem | 0:c385e589a779 | 42 | int currentFileSize; |
afilipem | 0:c385e589a779 | 43 | char* logFile; |
afilipem | 0:c385e589a779 | 44 | char* logFileBackup; |
afilipem | 0:c385e589a779 | 45 | int logFileStatus; // if things go wrong, don't write any more data to file |
afilipem | 0:c385e589a779 | 46 | |
afilipem | 0:c385e589a779 | 47 | void backupLog(); |
afilipem | 0:c385e589a779 | 48 | }; |
afilipem | 0:c385e589a779 | 49 | |
afilipem | 0:c385e589a779 | 50 | #endif |