custom for >5 resources
Fork of mbedConnectorInterface by
api/Logger.h@57:ef0fdadde9eb, 2015-05-20 (annotated)
- Committer:
- michaeljkoster
- Date:
- Wed May 20 00:46:01 2015 +0000
- Revision:
- 57:ef0fdadde9eb
- Parent:
- 16:383ad1356963
10 resources
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ansond | 0:b438482ebbfc | 1 | /** |
ansond | 0:b438482ebbfc | 2 | * @file Logger.h |
ansond | 0:b438482ebbfc | 3 | * @brief mbed CoAP Endpoint logging class |
ansond | 0:b438482ebbfc | 4 | * @author Doug Anson/Chris Paola |
ansond | 0:b438482ebbfc | 5 | * @version 1.0 |
sam_grove | 2:853f9ecc12df | 6 | * @see |
ansond | 0:b438482ebbfc | 7 | * |
ansond | 0:b438482ebbfc | 8 | * Copyright (c) 2014 |
ansond | 0:b438482ebbfc | 9 | * |
ansond | 0:b438482ebbfc | 10 | * Licensed under the Apache License, Version 2.0 (the "License"); |
ansond | 0:b438482ebbfc | 11 | * you may not use this file except in compliance with the License. |
ansond | 0:b438482ebbfc | 12 | * You may obtain a copy of the License at |
ansond | 0:b438482ebbfc | 13 | * |
ansond | 0:b438482ebbfc | 14 | * http://www.apache.org/licenses/LICENSE-2.0 |
ansond | 0:b438482ebbfc | 15 | * |
ansond | 0:b438482ebbfc | 16 | * Unless required by applicable law or agreed to in writing, software |
ansond | 0:b438482ebbfc | 17 | * distributed under the License is distributed on an "AS IS" BASIS, |
ansond | 0:b438482ebbfc | 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
ansond | 0:b438482ebbfc | 19 | * See the License for the specific language governing permissions and |
ansond | 0:b438482ebbfc | 20 | * limitations under the License. |
ansond | 0:b438482ebbfc | 21 | */ |
sam_grove | 2:853f9ecc12df | 22 | |
sam_grove | 2:853f9ecc12df | 23 | #ifndef __LOGGER_H__ |
sam_grove | 2:853f9ecc12df | 24 | #define __LOGGER_H__ |
sam_grove | 2:853f9ecc12df | 25 | |
sam_grove | 2:853f9ecc12df | 26 | // mbed API |
sam_grove | 2:853f9ecc12df | 27 | #include "mbed.h" |
sam_grove | 2:853f9ecc12df | 28 | |
sam_grove | 2:853f9ecc12df | 29 | // Support for std args |
sam_grove | 2:853f9ecc12df | 30 | #include <stdarg.h> |
sam_grove | 2:853f9ecc12df | 31 | |
ansond | 5:a929d65eb385 | 32 | // Configuration |
ansond | 5:a929d65eb385 | 33 | #include "mbedConnectorInterface.h" |
ansond | 5:a929d65eb385 | 34 | |
ansond | 5:a929d65eb385 | 35 | // logging macro |
ansond | 5:a929d65eb385 | 36 | #define log(x, ...) logIt(x"\r\n",##__VA_ARGS__) |
ansond | 5:a929d65eb385 | 37 | |
sam_grove | 2:853f9ecc12df | 38 | /** Logger class |
sam_grove | 2:853f9ecc12df | 39 | */ |
sam_grove | 2:853f9ecc12df | 40 | class Logger |
sam_grove | 2:853f9ecc12df | 41 | { |
sam_grove | 2:853f9ecc12df | 42 | public: |
sam_grove | 2:853f9ecc12df | 43 | /** |
sam_grove | 2:853f9ecc12df | 44 | Default constructor |
sam_grove | 2:853f9ecc12df | 45 | @param pc input BufferedSerial instance for debugging (if NULL, no debugging output will occur in the library) |
sam_grove | 2:853f9ecc12df | 46 | */ |
ansond | 16:383ad1356963 | 47 | Logger(const RawSerial *pc); |
ansond | 0:b438482ebbfc | 48 | |
sam_grove | 2:853f9ecc12df | 49 | /** |
sam_grove | 2:853f9ecc12df | 50 | Copy constructor |
sam_grove | 2:853f9ecc12df | 51 | @param logger input Logger instance to deep copy |
sam_grove | 2:853f9ecc12df | 52 | */ |
sam_grove | 2:853f9ecc12df | 53 | Logger(const Logger &logger); |
sam_grove | 2:853f9ecc12df | 54 | |
sam_grove | 2:853f9ecc12df | 55 | /** |
sam_grove | 2:853f9ecc12df | 56 | Destructor |
sam_grove | 2:853f9ecc12df | 57 | */ |
sam_grove | 2:853f9ecc12df | 58 | virtual ~Logger(); |
sam_grove | 2:853f9ecc12df | 59 | |
sam_grove | 2:853f9ecc12df | 60 | /** |
ansond | 5:a929d65eb385 | 61 | Log output to the given serial console |
sam_grove | 2:853f9ecc12df | 62 | @param format input format for the logging |
sam_grove | 2:853f9ecc12df | 63 | @param ... input (variable arguments to display) |
sam_grove | 2:853f9ecc12df | 64 | */ |
ansond | 5:a929d65eb385 | 65 | void logIt(const char *format, ...); |
sam_grove | 2:853f9ecc12df | 66 | protected: |
sam_grove | 2:853f9ecc12df | 67 | |
sam_grove | 2:853f9ecc12df | 68 | private: |
ansond | 16:383ad1356963 | 69 | RawSerial *m_pc; |
sam_grove | 2:853f9ecc12df | 70 | }; |
sam_grove | 2:853f9ecc12df | 71 | |
sam_grove | 2:853f9ecc12df | 72 | #endif // __LOGGER_H__ |