A common library used by Digi International Inc. mbed libraries to output debug information.

Dependents:   XBeeLib XBeeLib_Test Chi-XBee-Actuator Chi-XBee-Sensor ... more

A common library used by Digi International Inc. mbed libraries to output debug information.
Used by XBeeLib

See Debugging the library chapter for more info.

Committer:
spastor
Date:
Fri May 08 11:50:45 2015 +0200
Revision:
1:79cea2b2eea6
Parent:
0:e83acb8d505c
Child:
2:1f16339607b7
Automatic upload

Who changed what in which revision?

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