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