Fork of my original MQTTGateway
XbeeMonitor/XBeeLib/DigiLogger/DigiLogger.h@0:a1734fe1ec4b, 2017-04-08 (annotated)
- Committer:
- vpcola
- Date:
- Sat Apr 08 14:43:14 2017 +0000
- Revision:
- 0:a1734fe1ec4b
Initial commit
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| vpcola | 0:a1734fe1ec4b | 1 | /** |
| vpcola | 0:a1734fe1ec4b | 2 | * Copyright (c) 2015 Digi International Inc., |
| vpcola | 0:a1734fe1ec4b | 3 | * All rights not expressly granted are reserved. |
| vpcola | 0:a1734fe1ec4b | 4 | * |
| vpcola | 0:a1734fe1ec4b | 5 | * This Source Code Form is subject to the terms of the Mozilla Public |
| vpcola | 0:a1734fe1ec4b | 6 | * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
| vpcola | 0:a1734fe1ec4b | 7 | * You can obtain one at http://mozilla.org/MPL/2.0/. |
| vpcola | 0:a1734fe1ec4b | 8 | * |
| vpcola | 0:a1734fe1ec4b | 9 | * Digi International Inc. 11001 Bren Road East, Minnetonka, MN 55343 |
| vpcola | 0:a1734fe1ec4b | 10 | * ======================================================================= |
| vpcola | 0:a1734fe1ec4b | 11 | */ |
| vpcola | 0:a1734fe1ec4b | 12 | |
| vpcola | 0:a1734fe1ec4b | 13 | #if !defined(__DIGI_LOGGER_H_) |
| vpcola | 0:a1734fe1ec4b | 14 | #define __DIGI_LOGGER_H_ |
| vpcola | 0:a1734fe1ec4b | 15 | |
| vpcola | 0:a1734fe1ec4b | 16 | #include <cstdlib> |
| vpcola | 0:a1734fe1ec4b | 17 | #include <stdio.h> |
| vpcola | 0:a1734fe1ec4b | 18 | |
| vpcola | 0:a1734fe1ec4b | 19 | /** |
| vpcola | 0:a1734fe1ec4b | 20 | * @defgroup LogLevel |
| vpcola | 0:a1734fe1ec4b | 21 | * @{ |
| vpcola | 0:a1734fe1ec4b | 22 | */ |
| vpcola | 0:a1734fe1ec4b | 23 | /** |
| vpcola | 0:a1734fe1ec4b | 24 | * Library Logging level. |
| vpcola | 0:a1734fe1ec4b | 25 | */ |
| vpcola | 0:a1734fe1ec4b | 26 | enum LogLevel { |
| vpcola | 0:a1734fe1ec4b | 27 | LogLevelNone, /** Level None */ |
| vpcola | 0:a1734fe1ec4b | 28 | LogLevelError, /** Level Error */ |
| vpcola | 0:a1734fe1ec4b | 29 | LogLevelWarning, /** Level Warning */ |
| vpcola | 0:a1734fe1ec4b | 30 | LogLevelInfo, /** Level Info */ |
| vpcola | 0:a1734fe1ec4b | 31 | LogLevelDebug, /** Level Debug */ |
| vpcola | 0:a1734fe1ec4b | 32 | LogLevelFrameData, /** Level Frame Data */ |
| vpcola | 0:a1734fe1ec4b | 33 | LogLevelAll /** Level All */ |
| vpcola | 0:a1734fe1ec4b | 34 | }; |
| vpcola | 0:a1734fe1ec4b | 35 | /** |
| vpcola | 0:a1734fe1ec4b | 36 | * @} |
| vpcola | 0:a1734fe1ec4b | 37 | */ |
| vpcola | 0:a1734fe1ec4b | 38 | |
| vpcola | 0:a1734fe1ec4b | 39 | #define DEBUG_BUFFER_LEN 200 |
| vpcola | 0:a1734fe1ec4b | 40 | |
| vpcola | 0:a1734fe1ec4b | 41 | namespace DigiLog { |
| vpcola | 0:a1734fe1ec4b | 42 | |
| vpcola | 0:a1734fe1ec4b | 43 | class DigiLogger |
| vpcola | 0:a1734fe1ec4b | 44 | { |
| vpcola | 0:a1734fe1ec4b | 45 | protected: |
| vpcola | 0:a1734fe1ec4b | 46 | |
| vpcola | 0:a1734fe1ec4b | 47 | /** module log level */ |
| vpcola | 0:a1734fe1ec4b | 48 | static LogLevel _log_level; |
| vpcola | 0:a1734fe1ec4b | 49 | |
| vpcola | 0:a1734fe1ec4b | 50 | static DigiLogger* current_logger; |
| vpcola | 0:a1734fe1ec4b | 51 | |
| vpcola | 0:a1734fe1ec4b | 52 | /* Not implemented for base class */ |
| vpcola | 0:a1734fe1ec4b | 53 | virtual void log_buffer(char const * const buffer); |
| vpcola | 0:a1734fe1ec4b | 54 | |
| vpcola | 0:a1734fe1ec4b | 55 | public: |
| vpcola | 0:a1734fe1ec4b | 56 | |
| vpcola | 0:a1734fe1ec4b | 57 | /** Class constructor */ |
| vpcola | 0:a1734fe1ec4b | 58 | DigiLogger(); |
| vpcola | 0:a1734fe1ec4b | 59 | |
| vpcola | 0:a1734fe1ec4b | 60 | /** Class destructor */ |
| vpcola | 0:a1734fe1ec4b | 61 | virtual ~DigiLogger(); |
| vpcola | 0:a1734fe1ec4b | 62 | |
| vpcola | 0:a1734fe1ec4b | 63 | /** set_level - set logging level. |
| vpcola | 0:a1734fe1ec4b | 64 | * |
| vpcola | 0:a1734fe1ec4b | 65 | * @param log_level desired overall logging level |
| vpcola | 0:a1734fe1ec4b | 66 | */ |
| vpcola | 0:a1734fe1ec4b | 67 | static void set_level(LogLevel log_level); |
| vpcola | 0:a1734fe1ec4b | 68 | |
| vpcola | 0:a1734fe1ec4b | 69 | /** get_level - get logging level. |
| vpcola | 0:a1734fe1ec4b | 70 | * |
| vpcola | 0:a1734fe1ec4b | 71 | * @returns current overall logging level |
| vpcola | 0:a1734fe1ec4b | 72 | */ |
| vpcola | 0:a1734fe1ec4b | 73 | static LogLevel get_level(); |
| vpcola | 0:a1734fe1ec4b | 74 | |
| vpcola | 0:a1734fe1ec4b | 75 | /** log_format - logs a printf-like message. |
| vpcola | 0:a1734fe1ec4b | 76 | * |
| vpcola | 0:a1734fe1ec4b | 77 | * @param log_level logging level |
| vpcola | 0:a1734fe1ec4b | 78 | * @param format ... printf-like message |
| vpcola | 0:a1734fe1ec4b | 79 | */ |
| vpcola | 0:a1734fe1ec4b | 80 | static void log_format(LogLevel log_level, const char *format, ...); |
| vpcola | 0:a1734fe1ec4b | 81 | |
| vpcola | 0:a1734fe1ec4b | 82 | }; |
| vpcola | 0:a1734fe1ec4b | 83 | |
| vpcola | 0:a1734fe1ec4b | 84 | } /* namespace DigiLog */ |
| vpcola | 0:a1734fe1ec4b | 85 | |
| vpcola | 0:a1734fe1ec4b | 86 | #endif /* defined(__DIGI_LOGGER_H_) */ |
| vpcola | 0:a1734fe1ec4b | 87 | |
| vpcola | 0:a1734fe1ec4b | 88 | |
| vpcola | 0:a1734fe1ec4b | 89 |