/home/jpf/code/cc/project/cmil/util/Logger.h

Go to the documentation of this file.
00001 // =====================================================================================
00002 //       Filename:  Logger.h
00003 //    Description:  
00004 //        Version:  1.0
00005 //        Created:  02/16/2007 09:42:00 PM EST
00006 //       Revision:  none
00007 //       Compiler:  gcc 3.4.6
00008 // 
00009 //         Author:  John P. Feltz 
00010 //          Email:  jfeltz@gmail.com
00011 //          License:  Copyright (c) 2006-2007, John P. Feltz 
00012 //                    This program is free software; you can redistribute it and/or
00013 //                    modify it under the terms of the GNU General Public License as
00014 //                    published by the Free Software Foundation, version 2 of the
00015 //                    License.
00016 //                    This program is distributed in the hope that it will be
00017 //                    useful, but WITHOUT ANY WARRANTY; without even the implied
00018 //                    warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00019 //                    PURPOSE.
00020 //                    See the GNU General Public License version 2 for more details.
00021 // 
00022 // =====================================================================================
00023 
00024   class LogManager {
00025     public:
00026       virtual ~LogManager() {}
00027       LogManager() : m_app_name(""), m_log_debug(true), m_log_errors(true) {}
00028 
00029       void setDebugOption(bool debug);
00030       void setErrorOption(bool errors); 
00031 
00032       virtual void log_error(const std::string& name, const std::string& message) const {
00033         if(m_log_errors)  
00034           std::cout << "   error: " << name << " :: " << message << std::endl;
00035       }
00036       virtual void log_debug(const std::string& name, const std::string& message) const{
00037         if(m_log_debug) 
00038           std::cout << "debug: " << name << " :: " << message << std::endl;
00039       }
00040 
00041     private:
00042       const std::string m_app_name;
00043       bool m_log_debug;
00044       bool m_log_errors;
00045   };
00046 
00047 
00048   class Logger {
00049     public:
00050       typedef SingletonNoArg<LogManager> sLogManager; 
00051       virtual ~Logger() {};
00052 
00053       void log_error(const std::string& message) const {
00054         sLogManager::getInstance()->log_error(getName(), message);
00055       }
00056 
00057       void log_debug(const std::string& message) const { 
00058         sLogManager::getInstance()->log_debug(getName(), message);
00059       }
00060 
00061       virtual std::string getName() const = 0;
00062   };

(c) 2006-2007 John P. Feltz
Generated on Wed Jul 25 16:08:02 2007 for Common Media Input Layer by doxygen 1.4.7

SourceForge.net Logo