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