- Timestamp:
- 05/19/03 09:11:42 (21 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r2119 r2120 1 1 -*-*- END OF LINE -*-*- 2 2003/05/19: Thomas Bretz 3 4 * mbase/MEvtLoop.cc, mbase/MParList.cc, mbase/MTaskList.cc, 5 mfileio/MReadTree.cc, mfileio/MWriteRootFile.cc: 6 - use new manipulator 'underline' 7 8 * mbase/MLog.cc: 9 - added new underlining 10 - added blue color for debugging 11 12 * mbase/MLogManip.[h,cc]: 13 - added underline 14 - added dbg and increased all other debug(n) levels by one 15 16 * mbase/MParContainer.h: 17 - made fDisplay persistent (workaround for a obsolete warning in 18 root 3.02/07) 19 20 * mfileio/MWriteRootFile.[h,cc]: 21 - fixed a bug introduced when implementing UPDATE mode, 22 kIsNewTree set for TTree 23 24 2 25 3 26 2003/05/16: Abelardo Moralejo … … 6 29 - Added SetCoeff 7 30 31 32 8 33 2003/05/16: Thomas Bretz 34 35 * mfilter/MFEventSelector2.[h,cc]: 36 - added 37 38 * mfilter/Makefile, mfilter/FilterLinkDef.h: 39 - added MFEventSelector2 9 40 10 41 * mbase/MContinue.cc: -
trunk/MagicSoft/Mars/mbase/MEvtLoop.cc
r2117 r2120 108 108 fName = name; 109 109 110 fLog->Underline(); 111 *fLog << inf << "Instantiated MEvtLoop (" << name << "), using ROOT v" << ROOTVER << endl; 110 *fLog << inf << underline << "Instantiated MEvtLoop (" << name << "), using ROOT v" << ROOTVER << endl; 112 111 } 113 112 -
trunk/MagicSoft/Mars/mbase/MLog.cc
r2106 r2120 25 25 26 26 ////////////////////////////////////////////////////////////////////////////// 27 // // 28 // MLog // 29 // // 30 // This is what we call the logging-system. // 31 // // 32 // It is derived from the C++ streaming classes and can handle our // 33 // logging. The log output can be redirected to stdout, stderr, any other // 34 // stream or a root window. // 35 // // 36 // There is a global log-instance which you can use like cout, id is gLog. // 37 // A log-instance of your choice (gLog by default) is destributed to all // 38 // Task which are used in an eventloop, so that you can redirect the output // 39 // of one eventloop to where you want.. // 40 // // 41 // The MLog stream has the advantage, that it can be used like the common // 42 // C++ streams (for example cout). It can redirect the stream to different // 43 // outputs (console, file, GUI) if necessary at the same time. // 44 // // 45 // It supports different debug levels. The debug level of the current // 46 // stream contents is set by SetDebugLevel, the output level of the // 47 // current stream can be set by SetOutputLevel. // 48 // // 49 // The header file MLogManip.h contains so called manipulators (like flush // 50 // or setw from iomanip.h) which can manipulate these levels from within // 51 // stream, for example: // 52 // gLog << debug(3) << "Hallo World " << endl; // 53 // sets the debug level of the following stream to 3 // 54 // // 55 // edev(), ddev() can be used to enable/disable an output device from // 56 // within the stream. The enumerations are defined in MLog::_flags // 57 // // 58 // Commonly used abbreviations are also defined: // 59 // dbginf Prints source file name and line number. Used for output // 60 // which people may like to look up in the code // 61 // all Is streamed to the output in any case. Used for outputs // 62 // which are requested by the user (eg TObject::Print) // 63 // err Should be used for fatal errors which stops the current // 64 // processing, eg: // 65 // gLog << err << "ERROR: TObject::Copy - Stopped" << endl; // 66 // warn Warning means an error occured, but it is not clear whether // 67 // this results further procesing or not. // 68 // inf Informs the user about what's going on. Mostly usefull for // 69 // debugging, but in general not necessary at all. // 70 // // 71 // gLog is a global stream defined like cout or cerr // 72 // // 27 // 28 // MLog 29 // 30 // This is what we call the logging-system. 31 // 32 // It is derived from the C++ streaming classes and can handle our 33 // logging. The log output can be redirected to stdout, stderr, any other 34 // stream or a root window. 35 // 36 // There is a global log-instance which you can use like cout, id is gLog. 37 // A log-instance of your choice (gLog by default) is destributed to all 38 // Task which are used in an eventloop, so that you can redirect the output 39 // of one eventloop to where you want.. 40 // 41 // The MLog stream has the advantage, that it can be used like the common 42 // C++ streams (for example cout). It can redirect the stream to different 43 // outputs (console, file, GUI) if necessary at the same time. 44 // 45 // It supports different debug levels. The debug level of the current 46 // stream contents is set by SetDebugLevel, the output level of the 47 // current stream can be set by SetOutputLevel. 48 // 49 // The header file MLogManip.h contains so called manipulators (like flush 50 // or setw from iomanip.h) which can manipulate these levels from within 51 // stream, for example: 52 // gLog << debug(3) << "Hallo World " << endl; 53 // sets the debug level of the following stream to 3 54 // 55 // edev(), ddev() can be used to enable/disable an output device from 56 // within the stream. The enumerations are defined in MLog::_flags 57 // 58 // Commonly used abbreviations are also defined: 59 // dbginf Prints source file name and line number. Used for output 60 // which people may like to look up in the code 61 // all Is streamed to the output in any case. Used for outputs 62 // which are requested by the user (eg TObject::Print) 63 // err Should be used for fatal errors which stops the current 64 // processing, eg: 65 // gLog << err << "ERROR: TObject::Copy - Stopped" << endl; 66 // warn Warning means an error occured, but it is not clear whether 67 // this results further procesing or not. 68 // inf Informs the user about what's going on. Mostly usefull for 69 // debugging, but in general not necessary at all. 70 // dbg Use this for your private purpose to mark something as debug 71 // output. This is _not_ ment to be persistent! 72 // 73 // If your console is capable of ANSI colors the stream is displayed 74 // in several colors: 75 // all: default 76 // err: red 77 // warn: yellow/brown 78 // inf: green 79 // dbg: blue (and all other levels) 80 // 81 // If you have a dark background on your console you might want to set 82 // an environment variable, eg: 83 // export MARSDEFINES=-DHAVE_DARKBACKGROUND 84 // and recompile MLog. 85 // 86 // If your console can display it also 'underline' can be used. This 87 // underlines a text till the next 'endl', eg: 88 // gLog << underline << "This is important!" << endl; 89 // 90 // To switch off ANSI support call: SetNoColors() 91 // 92 // gLog is a global stream defined like cout or cerr 93 // 73 94 ////////////////////////////////////////////////////////////////////////////// 74 95 … … 99 120 const char *const MLog::kYellow = "\033[33m"; 100 121 #endif 122 const char *const MLog::kBlue = "\033[34m"; 101 123 const char *const MLog::kUnderline = "\033[4m";; 102 124 const char *const MLog::kBlink = "\033[5m";; … … 197 219 void MLog::Underline() 198 220 { 221 SetBit(kIsUnderlined); 222 199 223 if (TestBit(eNoColors)) 200 224 return; … … 212 236 switch (fOutputLevel) 213 237 { 214 case 0: out << MLog::kReset; break; // all // maybe not necessary? 238 // do not output reset. Otherwise we reset underline in 0-mode 239 // case 1: out << MLog::kReset; break; // all 240 case 0: break; // all = background color 215 241 case 1: out << MLog::kRed; break; // err 216 242 case 2: out << MLog::kYellow; break; // warn 217 243 case 3: out << MLog::kGreen; break; // inf 244 default: out << MLog::kBlue; break; // all others (dbg) 218 245 } 219 246 … … 221 248 { 222 249 // Check for EOL 223 const Bool_t endline = fBase[len-1]=='\n';250 const Int_t endline = fBase[len-1]=='\n' ? 1 : 0; 224 251 // output text to screen (without trailing '\n') 225 out << TString(fBase, endline ? len-1 : len);252 out << TString(fBase, len-endline); 226 253 // reset colors if working with colors 227 254 if (!TestBit(eNoColors)) … … 229 256 // output EOL of check found EOL 230 257 if (endline) 258 { 231 259 out << '\n'; 260 // Check whether text was underlined 261 if (TestBit(kIsUnderlined) && TestBit(eNoColors)) 262 { 263 out << setw(len-1) << setfill('-') << "" << "\n"; 264 ResetBit(kIsUnderlined); 265 } 266 } 232 267 } 233 268 out.flush(); 269 } 270 271 void MLog::AddGuiLine(const TString &line) 272 { 273 // add a new TString* to the array of gui lines 274 TString **newstr = new TString*[fNumLines+1]; 275 memcpy(newstr, fGuiLines, fNumLines*sizeof(TString*)); 276 if (fNumLines>0) 277 delete fGuiLines; 278 fGuiLines = newstr; 279 280 // add Gui line as last line of array 281 fGuiLines[fNumLines++] = new TString(line); 234 282 } 235 283 … … 263 311 { 264 312 // check whether the current text was flushed or endl'ed 265 const Bool_t flushed = fBase[len-1]!='\n';313 const Int_t endline = fBase[len-1]=='\n' ? 1 : 0; 266 314 267 315 // for the gui remove trailing characters ('\n' or '\0') 268 fBase[ flushed ? len : len-1]='\0';316 fBase[len-endline]='\0'; 269 317 270 318 // add new text to line storage 271 319 fGuiLine += fBase; 272 320 273 if ( !flushed)321 if (endline) 274 322 { 275 // add a new TString* to the array of gui lines 276 TString **newstr = new TString*[fNumLines+1]; 277 memcpy(newstr, fGuiLines, fNumLines*sizeof(TString*)); 278 if (fNumLines>0) 279 delete fGuiLines; 280 fGuiLines = newstr; 281 282 // add Gui line as last line of array 283 fGuiLines[fNumLines++] = new TString(fGuiLine); 323 AddGuiLine(fGuiLine); 284 324 fGuiLine = ""; 325 326 // Check whether text should be underlined 327 if (endline && TestBit(kIsUnderlined)) 328 { 329 AddGuiLine(""); 330 fGuiLines[fNumLines-1]->Append('-', fGuiLines[fNumLines-2]->Length()); 331 ResetBit(kIsUnderlined); 332 } 285 333 } 286 334 } -
trunk/MagicSoft/Mars/mbase/MLogManip.cc
r2100 r2120 107 107 } 108 108 109 ostream& underline(ostream& lout) 110 { 111 // 112 // get the streambuf of the stream 113 // get the pointer to the parent class by casting 114 // Disable an output device of the logging stream, it should 115 // be possible to disable more than one output device at the 116 // same time by oring them together 117 // 118 // Be careful: This manipulator can only be used in MLogging 119 // streams - in other streams SetOutputLevel is a call 120 // of a non existing function 121 // 122 MLog *log=(MLog*)lout.rdbuf(); 123 log->Underline(); 124 return lout; 125 } 126 -
trunk/MagicSoft/Mars/mbase/MLogManip.h
r1080 r2120 11 11 // define a general simple macro for manipulator definitions (int) 12 12 // 13 #define MANIPULATOR0(name) \ 14 extern ostream& ##name(ostream& lout); 15 13 16 #ifndef OMANIP 14 15 #define MANIPULATOR(name) \ 16 extern ostream& __omanip_##name(ostream& lout, int i); \ 17 inline omanip<int> ##name(int i) \ 18 { \ 19 return omanip<int>(__omanip_##name, i); \ 20 } 17 #define MANIPULATOR1(name) \ 18 extern ostream& __omanip_##name(ostream& lout, int i); \ 19 inline omanip<int> ##name(int i) \ 20 { \ 21 return omanip<int>(__omanip_##name, i); \ 22 } 21 23 22 24 #else 23 24 #define MANIPULATOR(name) \ 25 extern ostream& __omanip_##name(ostream& lout, int i); \ 26 inline OMANIP(int) ##name(int i) \ 27 { \ 28 return OMANIP(int)(__omanip_##name, i); \ 29 } 25 #define MANIPULATOR1(name) \ 26 extern ostream& __omanip_##name(ostream& lout, int i); \ 27 inline OMANIP(int) ##name(int i) \ 28 { \ 29 return OMANIP(int)(__omanip_##name, i); \ 30 } 30 31 31 32 #endif 33 32 34 // 33 35 // definitions 34 36 // 35 MANIPULATOR(debug); // set debug level 36 MANIPULATOR(device); // set ouput devices 37 MANIPULATOR(edev); // enable additional output devices 38 MANIPULATOR(ddev); // disable given output 37 MANIPULATOR0(underline); // underline output 38 MANIPULATOR1(debug); // set debug level 39 MANIPULATOR1(device); // set ouput devices 40 MANIPULATOR1(edev); // enable additional output devices 41 MANIPULATOR1(ddev); // disable given output 39 42 //#ifndef __CINT__ 40 43 //__DEFINE_IOMANIP_FN1(smanip, int, debug); // set debug level … … 53 56 // 54 57 #ifndef __CINT__ 55 #define dbginf __FILE__ << " l." << dec << __LINE__ << ": " 56 #define all debug(0) 57 #define err debug(1) 58 #define warn debug(2) 59 #define inf debug(3) 58 #define dbginf dbg << __FILE__ << " l." << dec << __LINE__ << ": " 59 #define all debug(0) // use this for output in any case 60 #define err debug(1) // use this for fatal errors (red) 61 #define warn debug(2) // use this for wrnings (yellow) 62 #define inf debug(3) // use this for informations (green) 63 #define dbg debug(4) // use this for debug messages (blue) 60 64 #endif 61 65 // -
trunk/MagicSoft/Mars/mbase/MParContainer.h
r1965 r2120 36 36 MLog *fLog; // The general log facility for this object, initialized with the global object 37 37 38 MStatusDisplay *fDisplay; 38 // This data member was added later, because for calculating the 39 // Checksum root (3.02/07) ignores ClassDef=0 all data members 40 // which are not persistent (//!) are used. To make the two 41 // class versions CheckSum-compatible (only getting rid of a 42 // warning) this member is persistent. 43 MStatusDisplay *fDisplay; //! 39 44 40 45 private: -
trunk/MagicSoft/Mars/mbase/MParList.cc
r2052 r2120 503 503 void MParList::Print(Option_t *t) const 504 504 { 505 *fLog << all << " " << GetDescriptor() << endl; 506 *fLog << setfill('-') << setw(strlen(GetDescriptor())+2) << "" << endl; 505 *fLog << all << underline << GetDescriptor() << ":" << endl; 507 506 508 507 MParContainer *obj = NULL; -
trunk/MagicSoft/Mars/mbase/MTaskList.cc
r2117 r2120 549 549 if (lvl==0) 550 550 { 551 *fLog << all << endl; 552 *fLog << "Execution Statistics: " << endl; 553 *fLog << "---------------------" << endl; 551 *fLog << all << underline << "Execution Statistics:" << endl; 554 552 *fLog << GetDescriptor(); 555 553 if (GetFilter()) … … 580 578 void MTaskList::Print(Option_t *t) const 581 579 { 582 *fLog << all << endl; 583 *fLog << GetDescriptor() << endl; 584 *fLog << setfill('-') << setw(strlen(GetDescriptor())) << "" << endl; 580 *fLog << all << underline << GetDescriptor() << ":" << endl; 585 581 586 582 fTasks->Print(); -
trunk/MagicSoft/Mars/mfileio/MReadTree.cc
r2117 r2120 895 895 void MReadTree::Print(Option_t *o) const 896 896 { 897 *fLog << all << GetDescriptor() << dec << endl; 898 *fLog << setfill('-') << setw(strlen(GetDescriptor())) << "" << endl; 897 *fLog << all << underline << GetDescriptor() << ":" << endl << dec; 899 898 *fLog << " Files [Tree]:" << endl; 900 899 -
trunk/MagicSoft/Mars/mfileio/MWriteRootFile.cc
r2002 r2120 140 140 void MWriteRootFile::Print(Option_t *) const 141 141 { 142 *fLog << all << " File: " << GetFileName() << endl; 143 *fLog << setfill('-') << setw(strlen(GetFileName())+8) << "" << endl; 144 *fLog << setfill(' '); // FIXME: not resetting setfill results in strange output??? 142 *fLog << all << underline << "File: " << GetFileName() << ":" << endl; 145 143 146 144 TTree *t = NULL; … … 278 276 // tree as a branch created by MWriteRootFile 279 277 // 280 entry->SetBit(kIsNewTree);278 tree->SetBit(kIsNewTree); 281 279 282 280 gDirectory = save; … … 358 356 void MWriteRootFile::CheckAndWrite() const 359 357 { 360 const Int_t kFillTree = BIT(14);361 362 358 TObject *obj; 363 359 … … 380 376 // the corresponding tree entry. 381 377 // 382 if (b-> TestBit(kIsNewTree))378 if (b->GetTree()->TestBit(kIsNewTree)) 383 379 b->GetTree()->SetBit(kFillTree); 384 380 else -
trunk/MagicSoft/Mars/mfileio/MWriteRootFile.h
r2002 r2120 81 81 82 82 enum { 83 kFillTree = BIT(14), 83 84 kIsNewTree = BIT(15) 84 85 };
Note:
See TracChangeset
for help on using the changeset viewer.