Fork of my MQTTGateway

Dependencies:   mbed-http

Committer:
vpcola
Date:
Sat Apr 08 14:45:51 2017 +0000
Revision:
0:f1d3878b8dd9
Initial commit

Who changed what in which revision?

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