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

In This Package:

Logging Namespace Reference


Functions

std::string FormString (const char *fmt,...)
string LevelToString (Level lvl)
Level StringToLevel (string str)
std::string FormString (const char *fmt,...)

Function Documentation

std::string Logging::FormString ( const char *  fmt,
  ... 
)

Definition at line 8 of file FormString.cc.

00009 {
00010   static int sBufSize = 100;
00011   static char* sBuffer = new char[sBufSize];
00012   
00013   va_list ap;
00014   va_start(ap,fmt);
00015   int res = vsnprintf(sBuffer, sBufSize, fmt, ap);
00016   va_end(ap);
00017         if(res >= sBufSize) {
00018           sBufSize = res+20;
00019     //std::cerr << "Increasing buffer size to " << sBufSize << std::endl;
00020           delete [] sBuffer;
00021     sBuffer = new char[sBufSize];
00022     
00023     // And try again.
00024     va_list ap2;
00025     va_start(ap2,fmt);
00026     vsnprintf(sBuffer, sBufSize, fmt, ap2);
00027     va_end(ap2);    
00028   }
00029         
00030   return std::string(sBuffer);  
00031 }

string Logging::LevelToString ( Level  lvl  ) 

Definition at line 79 of file Level.cc.

00080 {
00081   // Get the table.
00082   SynonymTable_t& sTable = GetSynonymTable();
00083 
00084   // Look for the first direct match.
00085   for(int i=0;i<sTable.size();i++) {
00086     if(lvl == sTable[i].first) return sTable[i].second;
00087   }
00088 
00089   // Hmmm, no direct matches.  Return the raw number.
00090   char temp[10];
00091   sprintf(temp,"%d",lvl);
00092   return string(temp);
00093 }

Level Logging::StringToLevel ( string  str  ) 

Definition at line 95 of file Level.cc.

00096 {
00097   // Get the table.
00098   SynonymTable_t& sTable = GetSynonymTable();
00099 
00100   // Look for the first direct match.
00101   for(int i=0;i<sTable.size();i++){
00102     const char* strc = str.c_str();
00103     if(strncasecmp(strc,sTable[i].second.c_str(),sTable[i].second.length()) == 0) {
00104       // We have an exact match!
00105       return sTable[i].first;
00106     }
00107   }
00108   
00109   // Try to interpret it as a numeric.
00110   int lvl;
00111   int res = sscanf(str.c_str(),"%d",&lvl);
00112   if(res>0) return (Level)lvl;
00113   
00114   // Can't find anything. return null value..
00115   return kInvalid;
00116 }

std::string Logging::FormString ( const char *  fmt,
  ... 
)

Definition at line 7 of file FormString.cc.

00008 {
00009   static int sBufSize = 10;
00010   static char* sBuffer = new char[sBufSize];
00011   
00012   va_list ap;
00013   va_start(ap,fmt);
00014   int res = vsnprintf(sBuffer, sBufSize, fmt, ap);
00015   va_end(ap);
00016         if(res > sBufSize) {
00017           sBufSize = res+20;
00018     std::cerr << "Increasing buffer size to " << sBufSize << std::endl;
00019           delete [] sBuffer;
00020     sBuffer = new char[sBufSize];
00021     
00022     // And try again.
00023     va_list ap2;
00024     va_start(ap2,fmt);
00025     int res = vsnprintf(sBuffer, sBufSize, fmt, ap2);
00026     res = 0; // quell unused variable warnings
00027     va_end(ap2);    
00028   }
00029         
00030   return std::string(sBuffer);  
00031 }

| 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