Helpful logging and error format

Dependents:   Waldo_Embed_V2

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers LogUtil.cpp Source File

LogUtil.cpp

Go to the documentation of this file.
00001 /**
00002  * @file    LogUtil.cpp
00003  * @brief   Utility to log messages during runtime
00004  * @author  sam grove
00005  * @version 1.0
00006  * @see     http://www.drdobbs.com/cpp/a-lightweight-logger-for-c/240147505
00007  *
00008  * Copyright (c) 2013
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 "LogUtil.h"
00024  #include "mbed.h"
00025  
00026 LogUtil::LogUtil(BufferedSerial &serial, uint32_t baudrate)
00027 {
00028     _serial = &serial;
00029     (baudrate > 0) ? _serial->baud(baudrate) : __nop();
00030     _serial->printf("\033[2J");  // clear the terminal
00031     _serial->printf("\033[1;1H");// and set the cursor to home
00032     wait(0.5f);
00033     return;
00034 }
00035      
00036  
00037