mbed Connector Interface simplification API on top of mbed-client
Fork of mbedConnectorInterfaceV3 by
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!
source/Logger.cpp@14:d9ce4e56684e, 2016-06-09 (annotated)
- Committer:
- ansond
- Date:
- Thu Jun 09 19:05:18 2016 +0000
- Revision:
- 14:d9ce4e56684e
- Parent:
- 0:1f1f55e73248
- Child:
- 33:1d0b855df5a5
updates for DM functions
Who changed what in which revision?
User | Revision | Line number | New 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 | 14:d9ce4e56684e | 23 | #include "mbed-connector-interface/Logger.h" |
ansond | 14:d9ce4e56684e | 24 | |
ansond | 14:d9ce4e56684e | 25 | // Constructor |
ansond | 14:d9ce4e56684e | 26 | Logger::Logger(const Serial *pc) |
ansond | 14:d9ce4e56684e | 27 | { |
ansond | 14:d9ce4e56684e | 28 | this->m_pc = (Serial *)pc; |
ansond | 14:d9ce4e56684e | 29 | } |
ansond | 0:1f1f55e73248 | 30 | |
ansond | 14:d9ce4e56684e | 31 | // Copy Constructor |
ansond | 14:d9ce4e56684e | 32 | Logger::Logger(const Logger &logger) |
ansond | 14:d9ce4e56684e | 33 | { |
ansond | 14:d9ce4e56684e | 34 | this->m_pc = logger.m_pc; |
ansond | 14:d9ce4e56684e | 35 | } |
ansond | 14:d9ce4e56684e | 36 | |
ansond | 14:d9ce4e56684e | 37 | // Destructor |
ansond | 14:d9ce4e56684e | 38 | Logger::~Logger() |
ansond | 14:d9ce4e56684e | 39 | { |
ansond | 14:d9ce4e56684e | 40 | } |
ansond | 14:d9ce4e56684e | 41 | |
ansond | 14:d9ce4e56684e | 42 | // Log the ouput to the attached serial console |
ansond | 14:d9ce4e56684e | 43 | void Logger::logIt(const char *format,...) |
ansond | 14:d9ce4e56684e | 44 | { |
ansond | 14:d9ce4e56684e | 45 | #if !defined(QUIET_LOGGING) |
ansond | 14:d9ce4e56684e | 46 | // build the variable args into a string |
ansond | 14:d9ce4e56684e | 47 | va_list args; |
ansond | 14:d9ce4e56684e | 48 | char buffer[LOGGER_BUFFER_LENGTH+1]; |
ansond | 14:d9ce4e56684e | 49 | memset(buffer,0,LOGGER_BUFFER_LENGTH+1); |
ansond | 14:d9ce4e56684e | 50 | va_start(args, format); |
ansond | 14:d9ce4e56684e | 51 | vsnprintf(buffer,LOGGER_BUFFER_LENGTH,format,args); |
ansond | 14:d9ce4e56684e | 52 | |
ansond | 14:d9ce4e56684e | 53 | // clean up... |
ansond | 14:d9ce4e56684e | 54 | va_end(args); |
ansond | 14:d9ce4e56684e | 55 | |
ansond | 14:d9ce4e56684e | 56 | // print it... |
ansond | 14:d9ce4e56684e | 57 | if (this->m_pc != NULL) |
ansond | 14:d9ce4e56684e | 58 | this->m_pc->printf("%s",buffer); |
ansond | 14:d9ce4e56684e | 59 | // else |
ansond | 14:d9ce4e56684e | 60 | // std::printf("%s",buffer); |
ansond | 14:d9ce4e56684e | 61 | #endif |
ansond | 14:d9ce4e56684e | 62 | } |
ansond | 14:d9ce4e56684e | 63 |