00001 /*************************************************************************** 00002 * 00003 * $Id: StDbMessenger.cc,v 1.4 2004/01/15 00:02:25 fisyak Exp $ 00004 * 00005 * Author: R. Jeff Porter 00006 *************************************************************************** 00007 * 00008 * Description: Implementation of StDbMessService used within StDbLib 00009 * in stand-alone mode 00010 * 00011 *************************************************************************** 00012 * 00013 * $Log: StDbMessenger.cc,v $ 00014 * Revision 1.4 2004/01/15 00:02:25 fisyak 00015 * Replace ostringstream => StString, add option for alpha 00016 * 00017 * Revision 1.3 2003/09/16 22:44:17 porter 00018 * got rid of all ostrstream objects; replaced with StString+string. 00019 * modified rules.make and added file stdb_streams.h for standalone compilation 00020 * 00021 * Revision 1.2 2003/09/02 17:57:49 perev 00022 * gcc 3.2 updates + WarnOff 00023 * 00024 * Revision 1.1 2001/01/22 18:37:57 porter 00025 * Update of code needed in next year running. This update has little 00026 * effect on the interface (only 1 method has been changed in the interface). 00027 * Code also preserves backwards compatibility so that old versions of 00028 * StDbLib can read new table structures. 00029 * -Important features: 00030 * a. more efficient low-level table structure (see StDbSql.cc) 00031 * b. more flexible indexing for new systems (see StDbElememtIndex.cc) 00032 * c. environment variable override KEYS for each database 00033 * d. StMessage support & clock-time logging diagnostics 00034 * -Cosmetic features 00035 * e. hid stl behind interfaces (see new *Impl.* files) to again allow rootcint access 00036 * f. removed codes that have been obsolete for awhile (e.g. db factories) 00037 * & renamed some classes for clarity (e.g. tableQuery became StDataBaseI 00038 * and mysqlAccessor became StDbSql) 00039 * 00040 * 00041 **************************************************************************/ 00042 #include <string.h> 00043 #include "stdb_streams.h" 00044 #include "StDbMessenger.hh" 00045 00047 00048 void 00049 StDbMessenger::printMessage(const char* message, StDbMessLevel dbLevel, int lineNumber, const char* className, const char* methodName) { 00050 00051 if(dbLevel<mdbLevel)return; 00052 00053 char lString[64]; 00054 switch(dbLevel){ 00055 case dbMDebug: 00056 { 00057 strcpy(lString,"Debug"); 00058 break; 00059 } 00060 case dbMWarn: 00061 { 00062 strcpy(lString,"Warning"); 00063 break; 00064 } 00065 case dbMConnect: 00066 { 00067 strcpy(lString,"Info"); 00068 break; 00069 } 00070 case dbMErr: 00071 { 00072 strcpy(lString,"Error"); 00073 break; 00074 } 00075 default: 00076 { 00077 strcpy(lString," "); 00078 break; 00079 } 00080 } 00081 printMessage(message,(const char*)lString,lineNumber,className,methodName); 00082 } 00083 00085 00086 void 00087 StDbMessenger::printMessage(const char* message, const char* levelString, int lineNumber, const char* className, const char* methodName) { 00088 mos<<" *** "<<levelString<<" line="<<lineNumber<<" *** "; 00089 mos<<className<<"::"<<methodName<<" "<<endl<<message<<endl; 00090 } 00091 00092 00093 00094 00095