mbed Connector Endpoint interface. This interface permits a mbed endpoint to easily setup MDS resources and emit those resources to an MDS server.

Dependents:   IoT_LED_demo ServoTest uWater_Project hackathon ... more

Committer:
ansond
Date:
Tue Jan 27 22:23:51 2015 +0000
Revision:
0:b438482ebbfc
Child:
2:853f9ecc12df
initial check in

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ansond 0:b438482ebbfc 1 /**
ansond 0:b438482ebbfc 2 * @file Logger.cpp
ansond 0:b438482ebbfc 3 * @brief mbed CoAP Endpoint logging class
ansond 0:b438482ebbfc 4 * @author Doug Anson/Chris Paola
ansond 0:b438482ebbfc 5 * @version 1.0
ansond 0:b438482ebbfc 6 * @see
ansond 0:b438482ebbfc 7 *
ansond 0:b438482ebbfc 8 * Copyright (c) 2014
ansond 0:b438482ebbfc 9 *
ansond 0:b438482ebbfc 10 * Licensed under the Apache License, Version 2.0 (the "License");
ansond 0:b438482ebbfc 11 * you may not use this file except in compliance with the License.
ansond 0:b438482ebbfc 12 * You may obtain a copy of the License at
ansond 0:b438482ebbfc 13 *
ansond 0:b438482ebbfc 14 * http://www.apache.org/licenses/LICENSE-2.0
ansond 0:b438482ebbfc 15 *
ansond 0:b438482ebbfc 16 * Unless required by applicable law or agreed to in writing, software
ansond 0:b438482ebbfc 17 * distributed under the License is distributed on an "AS IS" BASIS,
ansond 0:b438482ebbfc 18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
ansond 0:b438482ebbfc 19 * See the License for the specific language governing permissions and
ansond 0:b438482ebbfc 20 * limitations under the License.
ansond 0:b438482ebbfc 21 */
ansond 0:b438482ebbfc 22
ansond 0:b438482ebbfc 23 #include "Logger.h"
ansond 0:b438482ebbfc 24
ansond 0:b438482ebbfc 25 // Constructor
ansond 0:b438482ebbfc 26 Logger::Logger(const BufferedSerial *pc) {
ansond 0:b438482ebbfc 27 this->m_pc = (BufferedSerial *)pc;
ansond 0:b438482ebbfc 28 }
ansond 0:b438482ebbfc 29
ansond 0:b438482ebbfc 30 // Copy Constructor
ansond 0:b438482ebbfc 31 Logger::Logger(const Logger &logger) {
ansond 0:b438482ebbfc 32 this->m_pc = logger.m_pc;
ansond 0:b438482ebbfc 33 }
ansond 0:b438482ebbfc 34
ansond 0:b438482ebbfc 35 // Destructor
ansond 0:b438482ebbfc 36 Logger::~Logger() {
ansond 0:b438482ebbfc 37 }
ansond 0:b438482ebbfc 38
ansond 0:b438482ebbfc 39 // Log output
ansond 0:b438482ebbfc 40 void Logger::log(const char *format,...) {
ansond 0:b438482ebbfc 41 va_list args;
ansond 0:b438482ebbfc 42 va_start(args,format);
ansond 0:b438482ebbfc 43 if (this->m_pc != NULL) {
ansond 0:b438482ebbfc 44 //this->m_pc->printf(format,args);
ansond 0:b438482ebbfc 45 //this->m_pc->printf("\r\n");
ansond 0:b438482ebbfc 46 std::printf(format,args);
ansond 0:b438482ebbfc 47 std::printf("\r\n");
ansond 0:b438482ebbfc 48 }
ansond 0:b438482ebbfc 49 else {
ansond 0:b438482ebbfc 50 std::printf(format,args);
ansond 0:b438482ebbfc 51 std::printf("\r\n");
ansond 0:b438482ebbfc 52 }
ansond 0:b438482ebbfc 53 va_end(args);
ansond 0:b438482ebbfc 54 }