mbed Connector Interface simplification API on top of mbed-client

Fork of mbedConnectorInterfaceV3 by Doug Anson

NOTE:

This repo has been replaced with https://github.com/ARMmbed/mbedConnectorInterface. No further updates will occur with this repo. Please use the github repo instead. Thanks!

Committer:
ansond
Date:
Tue Sep 26 16:01:31 2017 +0000
Revision:
127:b4a661ff6fb9
Parent:
33:1d0b855df5a5
minor re-ordering of FCC init

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ansond 14:d9ce4e56684e 1 /**
ansond 14:d9ce4e56684e 2 * @file Logger.cpp
ansond 14:d9ce4e56684e 3 * @brief mbed CoAP Endpoint logging class
ansond 14:d9ce4e56684e 4 * @author Doug Anson/Chris Paola
ansond 14:d9ce4e56684e 5 * @version 1.0
ansond 14:d9ce4e56684e 6 * @see
ansond 14:d9ce4e56684e 7 *
ansond 14:d9ce4e56684e 8 * Copyright (c) 2014
ansond 14:d9ce4e56684e 9 *
ansond 14:d9ce4e56684e 10 * Licensed under the Apache License, Version 2.0 (the "License");
ansond 14:d9ce4e56684e 11 * you may not use this file except in compliance with the License.
ansond 14:d9ce4e56684e 12 * You may obtain a copy of the License at
ansond 14:d9ce4e56684e 13 *
ansond 14:d9ce4e56684e 14 * http://www.apache.org/licenses/LICENSE-2.0
ansond 14:d9ce4e56684e 15 *
ansond 14:d9ce4e56684e 16 * Unless required by applicable law or agreed to in writing, software
ansond 14:d9ce4e56684e 17 * distributed under the License is distributed on an "AS IS" BASIS,
ansond 14:d9ce4e56684e 18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
ansond 14:d9ce4e56684e 19 * See the License for the specific language governing permissions and
ansond 14:d9ce4e56684e 20 * limitations under the License.
ansond 14:d9ce4e56684e 21 */
ansond 14:d9ce4e56684e 22
ansond 33:1d0b855df5a5 23 // Class support
ansond 14:d9ce4e56684e 24 #include "mbed-connector-interface/Logger.h"
ansond 14:d9ce4e56684e 25
ansond 14:d9ce4e56684e 26 // Constructor
ansond 14:d9ce4e56684e 27 Logger::Logger(const Serial *pc)
ansond 14:d9ce4e56684e 28 {
ansond 14:d9ce4e56684e 29 this->m_pc = (Serial *)pc;
ansond 14:d9ce4e56684e 30 }
ansond 0:1f1f55e73248 31
ansond 14:d9ce4e56684e 32 // Copy Constructor
ansond 14:d9ce4e56684e 33 Logger::Logger(const Logger &logger)
ansond 14:d9ce4e56684e 34 {
ansond 14:d9ce4e56684e 35 this->m_pc = logger.m_pc;
ansond 14:d9ce4e56684e 36 }
ansond 14:d9ce4e56684e 37
ansond 14:d9ce4e56684e 38 // Destructor
ansond 14:d9ce4e56684e 39 Logger::~Logger()
ansond 14:d9ce4e56684e 40 {
ansond 14:d9ce4e56684e 41 }
ansond 14:d9ce4e56684e 42
ansond 14:d9ce4e56684e 43 // Log the ouput to the attached serial console
ansond 14:d9ce4e56684e 44 void Logger::logIt(const char *format,...)
ansond 14:d9ce4e56684e 45 {
ansond 14:d9ce4e56684e 46 #if !defined(QUIET_LOGGING)
ansond 14:d9ce4e56684e 47 // build the variable args into a string
ansond 14:d9ce4e56684e 48 va_list args;
ansond 14:d9ce4e56684e 49 char buffer[LOGGER_BUFFER_LENGTH+1];
ansond 14:d9ce4e56684e 50 memset(buffer,0,LOGGER_BUFFER_LENGTH+1);
ansond 14:d9ce4e56684e 51 va_start(args, format);
ansond 14:d9ce4e56684e 52 vsnprintf(buffer,LOGGER_BUFFER_LENGTH,format,args);
ansond 14:d9ce4e56684e 53
ansond 14:d9ce4e56684e 54 // clean up...
ansond 14:d9ce4e56684e 55 va_end(args);
ansond 14:d9ce4e56684e 56
ansond 14:d9ce4e56684e 57 // print it...
ansond 14:d9ce4e56684e 58 if (this->m_pc != NULL)
ansond 14:d9ce4e56684e 59 this->m_pc->printf("%s",buffer);
ansond 14:d9ce4e56684e 60 // else
ansond 14:d9ce4e56684e 61 // std::printf("%s",buffer);
ansond 14:d9ce4e56684e 62 #endif
ansond 14:d9ce4e56684e 63 }
ansond 14:d9ce4e56684e 64