added max-age and content-format
Fork of mbedConnectorInterface by
api/Logger.cpp@16:383ad1356963, 2015-02-06 (annotated)
- Committer:
- ansond
- Date:
- Fri Feb 06 04:07:51 2015 +0000
- Revision:
- 16:383ad1356963
- Parent:
- 5:a929d65eb385
big updates for underlying re-org
Who changed what in which revision?
User | Revision | Line number | New 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 |
sam_grove | 2:853f9ecc12df | 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 | */ |
sam_grove | 2:853f9ecc12df | 22 | |
sam_grove | 2:853f9ecc12df | 23 | #include "Logger.h" |
sam_grove | 2:853f9ecc12df | 24 | |
sam_grove | 2:853f9ecc12df | 25 | // Constructor |
ansond | 16:383ad1356963 | 26 | Logger::Logger(const RawSerial *pc) |
sam_grove | 2:853f9ecc12df | 27 | { |
ansond | 16:383ad1356963 | 28 | this->m_pc = (RawSerial *)pc; |
sam_grove | 2:853f9ecc12df | 29 | } |
sam_grove | 2:853f9ecc12df | 30 | |
sam_grove | 2:853f9ecc12df | 31 | // Copy Constructor |
sam_grove | 2:853f9ecc12df | 32 | Logger::Logger(const Logger &logger) |
sam_grove | 2:853f9ecc12df | 33 | { |
sam_grove | 2:853f9ecc12df | 34 | this->m_pc = logger.m_pc; |
sam_grove | 2:853f9ecc12df | 35 | } |
sam_grove | 2:853f9ecc12df | 36 | |
sam_grove | 2:853f9ecc12df | 37 | // Destructor |
sam_grove | 2:853f9ecc12df | 38 | Logger::~Logger() |
sam_grove | 2:853f9ecc12df | 39 | { |
sam_grove | 2:853f9ecc12df | 40 | } |
sam_grove | 2:853f9ecc12df | 41 | |
ansond | 5:a929d65eb385 | 42 | // Log the ouput to the attached serial console |
ansond | 5:a929d65eb385 | 43 | void Logger::logIt(const char *format,...) |
ansond | 5:a929d65eb385 | 44 | { |
ansond | 5:a929d65eb385 | 45 | // build the variable args into a string |
ansond | 0:b438482ebbfc | 46 | va_list args; |
ansond | 5:a929d65eb385 | 47 | char buffer[LOGGER_BUFFER_LENGTH+1]; |
ansond | 5:a929d65eb385 | 48 | memset(buffer,0,LOGGER_BUFFER_LENGTH+1); |
ansond | 5:a929d65eb385 | 49 | va_start(args, format); |
ansond | 5:a929d65eb385 | 50 | vsnprintf(buffer,LOGGER_BUFFER_LENGTH,format,args); |
ansond | 5:a929d65eb385 | 51 | |
ansond | 5:a929d65eb385 | 52 | // clean up... |
ansond | 0:b438482ebbfc | 53 | va_end(args); |
ansond | 5:a929d65eb385 | 54 | |
ansond | 5:a929d65eb385 | 55 | // print it... |
ansond | 5:a929d65eb385 | 56 | if (this->m_pc != NULL) |
ansond | 5:a929d65eb385 | 57 | this->m_pc->printf("%s",buffer); |
ansond | 5:a929d65eb385 | 58 | else |
ansond | 5:a929d65eb385 | 59 | std::printf("%s",buffer); |
sam_grove | 2:853f9ecc12df | 60 | } |