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:
Mon Jun 01 18:59:28 2015 +0200
Revision:
5:58c5158b5120
Parent:
3:304026cffaf3
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 5:58c5158b5120 37 */
spastor 0:e83acb8d505c 38
spastor 0:e83acb8d505c 39 #define DEBUG_BUFFER_LEN 200
spastor 0:e83acb8d505c 40
spastor 0:e83acb8d505c 41 namespace DigiLog {
spastor 0:e83acb8d505c 42
spastor 0:e83acb8d505c 43 class DigiLogger
spastor 0:e83acb8d505c 44 {
spastor 0:e83acb8d505c 45 protected:
spastor 0:e83acb8d505c 46
spastor 0:e83acb8d505c 47 /** module log level */
spastor 0:e83acb8d505c 48 static LogLevel _log_level;
spastor 0:e83acb8d505c 49
spastor 0:e83acb8d505c 50 static DigiLogger* current_logger;
spastor 0:e83acb8d505c 51
spastor 0:e83acb8d505c 52 /* Not implemented for base class */
spastor 0:e83acb8d505c 53 virtual void log_buffer(char const * const buffer);
spastor 0:e83acb8d505c 54
spastor 0:e83acb8d505c 55 public:
spastor 0:e83acb8d505c 56
spastor 0:e83acb8d505c 57 /** Class constructor */
spastor 0:e83acb8d505c 58 DigiLogger();
spastor 0:e83acb8d505c 59
spastor 0:e83acb8d505c 60 /** Class destructor */
hbujanda 3:304026cffaf3 61 virtual ~DigiLogger();
spastor 0:e83acb8d505c 62
spastor 0:e83acb8d505c 63 /** set_level - set logging level.
spastor 0:e83acb8d505c 64 *
spastor 0:e83acb8d505c 65 * @param log_level desired overall logging level
spastor 0:e83acb8d505c 66 */
spastor 0:e83acb8d505c 67 static void set_level(LogLevel log_level);
spastor 0:e83acb8d505c 68
spastor 0:e83acb8d505c 69 /** get_level - get logging level.
spastor 0:e83acb8d505c 70 *
spastor 0:e83acb8d505c 71 * @returns current overall logging level
spastor 0:e83acb8d505c 72 */
spastor 5:58c5158b5120 73 static LogLevel get_level();
spastor 0:e83acb8d505c 74
spastor 0:e83acb8d505c 75 /** log_format - logs a printf-like message.
spastor 0:e83acb8d505c 76 *
spastor 0:e83acb8d505c 77 * @param log_level logging level
spastor 0:e83acb8d505c 78 * @param format ... printf-like message
spastor 0:e83acb8d505c 79 */
spastor 0:e83acb8d505c 80 static void log_format(LogLevel log_level, const char *format, ...);
spastor 0:e83acb8d505c 81
spastor 0:e83acb8d505c 82 };
spastor 0:e83acb8d505c 83
spastor 0:e83acb8d505c 84 } /* namespace DigiLog */
spastor 0:e83acb8d505c 85
spastor 0:e83acb8d505c 86 #endif /* defined(__DIGI_LOGGER_H_) */
spastor 0:e83acb8d505c 87
spastor 0:e83acb8d505c 88
spastor 0:e83acb8d505c 89