observe updates

Fork of mbedConnectorInterface by Doug Anson

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Logger.cpp Source File

Logger.cpp

Go to the documentation of this file.
00001 /**
00002  * @file    Logger.cpp
00003  * @brief   mbed CoAP Endpoint logging class
00004  * @author  Doug Anson/Chris Paola
00005  * @version 1.0
00006  * @see
00007  *
00008  * Copyright (c) 2014
00009  *
00010  * Licensed under the Apache License, Version 2.0 (the "License");
00011  * you may not use this file except in compliance with the License.
00012  * You may obtain a copy of the License at
00013  *
00014  *     http://www.apache.org/licenses/LICENSE-2.0
00015  *
00016  * Unless required by applicable law or agreed to in writing, software
00017  * distributed under the License is distributed on an "AS IS" BASIS,
00018  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00019  * See the License for the specific language governing permissions and
00020  * limitations under the License.
00021  */
00022 
00023 #include "Logger.h"
00024 
00025 // Constructor
00026 Logger::Logger(const RawSerial *pc)
00027 {
00028     this->m_pc = (RawSerial *)pc;
00029 }
00030 
00031 // Copy Constructor
00032 Logger::Logger(const Logger &logger)
00033 {
00034     this->m_pc = logger.m_pc;
00035 }
00036 
00037 // Destructor
00038 Logger::~Logger()
00039 {
00040 }
00041 
00042 // Log the ouput to the attached serial console
00043 void Logger::logIt(const char *format,...)
00044 {   
00045     // build the variable args into a string
00046     va_list args;
00047     char buffer[LOGGER_BUFFER_LENGTH+1];
00048     memset(buffer,0,LOGGER_BUFFER_LENGTH+1);
00049     va_start(args, format);
00050     vsnprintf(buffer,LOGGER_BUFFER_LENGTH,format,args);
00051     
00052     // clean up...
00053     va_end(args);
00054     
00055     // print it...
00056     if (this->m_pc != NULL)
00057         this->m_pc->printf("%s",buffer);
00058     else
00059         std::printf("%s",buffer);
00060 }