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 #include "DigiLoggerMbedSerial.h"
vpcola 0:f1d3878b8dd9 14
vpcola 0:f1d3878b8dd9 15 using namespace DigiLog;
vpcola 0:f1d3878b8dd9 16
vpcola 0:f1d3878b8dd9 17 Serial *DigiLoggerMbedSerial::_log_serial;
vpcola 0:f1d3878b8dd9 18
vpcola 0:f1d3878b8dd9 19 /* Class constructor when using a serial port as logging channel */
vpcola 0:f1d3878b8dd9 20 DigiLoggerMbedSerial::DigiLoggerMbedSerial(Serial * log_serial, LogLevel log_level)
vpcola 0:f1d3878b8dd9 21 {
vpcola 0:f1d3878b8dd9 22 _log_serial = log_serial;
vpcola 0:f1d3878b8dd9 23
vpcola 0:f1d3878b8dd9 24 _log_level = log_level;
vpcola 0:f1d3878b8dd9 25
vpcola 0:f1d3878b8dd9 26 DigiLogger::current_logger = this;
vpcola 0:f1d3878b8dd9 27 }
vpcola 0:f1d3878b8dd9 28
vpcola 0:f1d3878b8dd9 29 /* Class destructor */
vpcola 0:f1d3878b8dd9 30 DigiLoggerMbedSerial::~DigiLoggerMbedSerial()
vpcola 0:f1d3878b8dd9 31 {
vpcola 0:f1d3878b8dd9 32 _log_serial = NULL;
vpcola 0:f1d3878b8dd9 33 DigiLogger::current_logger = NULL;
vpcola 0:f1d3878b8dd9 34 }
vpcola 0:f1d3878b8dd9 35
vpcola 0:f1d3878b8dd9 36 void DigiLoggerMbedSerial::log_buffer(char const * const buffer)
vpcola 0:f1d3878b8dd9 37 {
vpcola 0:f1d3878b8dd9 38 if (_log_serial == NULL) {
vpcola 0:f1d3878b8dd9 39 return;
vpcola 0:f1d3878b8dd9 40 }
vpcola 0:f1d3878b8dd9 41
vpcola 0:f1d3878b8dd9 42 _log_serial->printf("%s", buffer);
vpcola 0:f1d3878b8dd9 43 fflush(*_log_serial);
vpcola 0:f1d3878b8dd9 44 }
vpcola 0:f1d3878b8dd9 45
vpcola 0:f1d3878b8dd9 46
vpcola 0:f1d3878b8dd9 47