| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

Log.cc

Go to the documentation of this file.
00001 
00002 #include "Log.hh"
00003 #include "LogStream.hh"
00004 #include "Manager.hh"
00005 #include <iostream>
00006 
00007 
00008 using namespace Logging;
00009 using namespace std;
00010 
00011 
00012 Log::Log( std::string name )
00013   : mCurrentLevel(Logging::kDefault)
00014   , mName(name)
00015 {
00016   // Register the name with the singleton.
00017   // Use singleton to get current log level and logger.
00018   Manager::Instance().RegisterLog(this);
00019 }
00020   
00021 
00022 Logging::Log::~Log()
00023 {
00024   // Deregister, just in case.
00025         Manager::Instance().DeRegisterLog(this);
00026   
00027   // Just in case we're accidentally called again, shut down the output streams.
00028   mConnectedStreams.clear();
00029 }
00030 
00031 
00032 void Logging::Log::WriteToStreams( Logging::Level lvl, 
00033                                    int line, 
00034                                    const char* file, 
00035                                    std::string msg )
00036 {
00037         // This function can be rewritten to put a new back-end on the 
00038   // logging service.  A very simple back-end can look like this:
00039 
00040         //if(IsEnabled(lvl))
00041         //  std::cout << "[" << log.GetName() << "]" << file << "::" << line << " | " << msg;
00042         
00043   if(!IsEnabled(lvl)) return;
00044   
00045   // Create a logentry and write it to all attached streams.
00046   for(std::set<LogStream*>::iterator it = mConnectedStreams.begin();
00047       it != mConnectedStreams.end();
00048       it++) {
00049     LogEntry entry(*this, lvl, msg, line, file);
00050     (*it)->WriteEntry( entry );
00051   }
00052 }
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Mon Apr 11 20:06:22 2011 for Log by doxygen 1.4.7