Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of mbedConnectorInterface by
api/Logger.cpp@2:853f9ecc12df, 2015-01-27 (annotated)
- Committer:
- sam_grove
- Date:
- Tue Jan 27 23:41:34 2015 +0000
- Revision:
- 2:853f9ecc12df
- Parent:
- 0:b438482ebbfc
- Child:
- 5:a929d65eb385
Use auto-format on code and add markup to render class documentation
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 |
sam_grove | 2:853f9ecc12df | 26 | Logger::Logger(const BufferedSerial *pc) |
sam_grove | 2:853f9ecc12df | 27 | { |
sam_grove | 2:853f9ecc12df | 28 | this->m_pc = (BufferedSerial *)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 | |
sam_grove | 2:853f9ecc12df | 42 | // Log output |
sam_grove | 2:853f9ecc12df | 43 | void Logger::log(const char *format,...) |
sam_grove | 2:853f9ecc12df | 44 | { |
ansond | 0:b438482ebbfc | 45 | va_list args; |
ansond | 0:b438482ebbfc | 46 | va_start(args,format); |
ansond | 0:b438482ebbfc | 47 | if (this->m_pc != NULL) { |
ansond | 0:b438482ebbfc | 48 | //this->m_pc->printf(format,args); |
ansond | 0:b438482ebbfc | 49 | //this->m_pc->printf("\r\n"); |
ansond | 0:b438482ebbfc | 50 | std::printf(format,args); |
ansond | 0:b438482ebbfc | 51 | std::printf("\r\n"); |
sam_grove | 2:853f9ecc12df | 52 | } else { |
ansond | 0:b438482ebbfc | 53 | std::printf(format,args); |
ansond | 0:b438482ebbfc | 54 | std::printf("\r\n"); |
ansond | 0:b438482ebbfc | 55 | } |
ansond | 0:b438482ebbfc | 56 | va_end(args); |
sam_grove | 2:853f9ecc12df | 57 | } |