Fork of my original MQTTGateway

Dependencies:   mbed-http

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers DigiLogger.cpp Source File

DigiLogger.cpp

00001 /**
00002  * Copyright (c) 2015 Digi International Inc.,
00003  * All rights not expressly granted are reserved.
00004  *
00005  * This Source Code Form is subject to the terms of the Mozilla Public
00006  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
00007  * You can obtain one at http://mozilla.org/MPL/2.0/.
00008  *
00009  * Digi International Inc. 11001 Bren Road East, Minnetonka, MN 55343
00010  * =======================================================================
00011  */
00012 
00013 #include "DigiLogger.h"
00014 
00015 #include <stdarg.h>
00016 
00017 using namespace DigiLog;
00018 
00019 LogLevel DigiLogger::_log_level;
00020 
00021 DigiLogger* DigiLogger::current_logger;
00022 
00023 /* Base Class constructor */
00024 DigiLogger::DigiLogger()
00025 {
00026     _log_level = LogLevelNone;
00027 
00028     current_logger = NULL;
00029 }
00030 
00031 /* Class destructor */
00032 DigiLogger::~DigiLogger()
00033 {
00034     current_logger = NULL;
00035 }
00036 
00037 void DigiLogger::set_level(LogLevel log_level)
00038 {
00039     _log_level = log_level;
00040 }
00041 
00042 LogLevel DigiLogger::get_level()
00043 {
00044     return _log_level;
00045 }
00046 
00047 void DigiLogger::log_format(LogLevel log_level, const char *format, ...)
00048 {
00049     static char buffer[DEBUG_BUFFER_LEN];
00050     va_list argp;
00051 
00052     if (current_logger == NULL) {
00053         return;
00054     }
00055 
00056     if (_log_level < log_level) {
00057         return;
00058     }
00059 
00060     va_start(argp, format);
00061     vsnprintf(buffer, DEBUG_BUFFER_LEN, format, argp);
00062     va_end(argp);
00063 
00064     current_logger->log_buffer(buffer);
00065 }
00066 
00067 void DigiLogger::log_buffer(char const * const buffer)
00068 {
00069     (void)(buffer);
00070 }