Project: engagement_recognition License: BSD Dependencies:
Used by:
None |
engagement_recognition/src/recognition/logger/console_logger.hGo to the documentation of this file.00001 /* 00002 * Software License Agreement (BSD License) 00003 * 00004 * Copyright (c) 2010, Worcester Polytechnic Institute 00005 * All rights reserved. 00006 * 00007 * Redistribution and use in source and binary forms, with or without 00008 * modification, are permitted provided that the following conditions 00009 * are met: 00010 * 00011 * * Redistributions of source code must retain the above copyright 00012 * notice, this list of conditions and the following disclaimer. 00013 * * Redistributions in binary form must reproduce the above 00014 * copyright notice, this list of conditions and the following 00015 * disclaimer in the documentation and/or other materials provided 00016 * with the distribution. 00017 * * Neither the name of Worcester Polytechnic Institute. nor the names 00018 * of its contributors may be used to endorse or promote products 00019 * derived from this software without specific prior written permission. 00020 * 00021 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00022 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00023 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00024 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00025 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00026 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00027 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00028 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00029 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00030 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 00031 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00032 * POSSIBILITY OF SUCH DAMAGE. 00033 */ 00034 #ifndef CONSOLE_LOGGER_H_ 00035 #define CONSOLE_LOGGER_H_ 00036 00037 #include <stdarg.h> 00038 #include <string> 00039 00050 class ConsoleLogger 00051 { 00052 private: 00054 std::string prefix_; 00055 00057 static std::string start_color; 00059 static std::string end_color; 00060 00062 static std::string DEFAULT; 00064 static std::string RED; 00066 static std::string GREEN; 00068 static std::string YELLOW; 00070 static std::string BLUE; 00072 static std::string PURPLE; 00074 static std::string CYAN; 00075 00077 static std::string BRIGHT_RED; 00079 static std::string BRIGHT_GREEN; 00081 static std::string BRIGHT_YELLOW; 00083 static std::string BRIGHT_BLUE; 00085 static std::string BRIGHT_PURPLE; 00087 static std::string BRIGHT_CYAN; 00088 00090 int verbosity_; 00091 00098 void createPrefix(std::string prefix, int color); 00099 public: 00103 ConsoleLogger(); 00104 00110 ConsoleLogger(std::string prefix); 00111 00118 ConsoleLogger(ConsoleLogger *logger, std::string prefix); 00119 00126 ConsoleLogger(std::string prefix, int color); 00127 00136 ConsoleLogger(ConsoleLogger *logger, std::string prefix, int color); 00137 00143 ConsoleLogger(ConsoleLogger *logger); 00144 00150 const char *getPrefix(); 00151 00158 void debug(int level, const char *str, va_list args); 00159 00165 void info(const char *str, va_list args); 00166 00172 void warn(const char *str, va_list args); 00173 00179 void error(const char *str, va_list args); 00180 00186 void fatal(const char *str, va_list args); 00187 00193 void red(const char *str, va_list args); 00194 00200 void green(const char *str, va_list args); 00201 00207 void yellow(const char *str, va_list args); 00208 00214 void blue(const char *str, va_list args); 00215 00221 void purple(const char *str, va_list args); 00222 00228 void cyan(const char *str, va_list args); 00229 00235 void brightRed(const char *str, va_list args); 00236 00242 void brightGreen(const char *str, va_list args); 00243 00249 void brightYellow(const char *str, va_list args); 00250 00256 void brightBlue(const char *str, va_list args); 00257 00263 void brightPurple(const char *str, va_list args); 00264 00270 void brightCyan(const char *str, va_list args); 00271 }; 00272 00273 #endif /* CONSOLE_LOGGER_H_ */ |