#include "MessageService/MsgService.h"Go to the source code of this file.
Functions | |
| CVSID ("$Id: TestDemo.cxx,v 1.3 2006/10/28 05:07:14 gmieg Exp $") | |
| void | theBasics () |
| void | fancyStuff () |
| void | fancyMessages () |
| void | manyMessageExample () |
| void | printStatistics () |
| int | main (void) |
|
||||||||||||
|
|
|
|
Definition at line 84 of file TestDemo.cxx. References MSG. Referenced by main(). 00085 {
00086 //======================================================================
00087 // Print some more messages just to make the example more interesting
00088 // Use the strem configured in "fancyStuff" above
00089 //======================================================================
00090
00091 try {
00092 MSG("Fan", Msg::kVerbose) << "This is a VERBOSE message\n";
00093 MSG("Fan", Msg::kDebug) << "This is a DEBUG message\n";
00094 MSG("Fan", Msg::kInfo) << "This is an INFO message\n";
00095 MSG("Fan", Msg::kWarning) << "This is a WARNING message\n";
00096 MSG("Fan", Msg::kError) << "This is an ERROR message\n";
00097 MSG("Fan", Msg::kFatal) << "This is a FATAL message\n";
00098 }
00099 catch(MSGException) {
00100 cerr << endl << endl;
00101 cerr << "***************** MSGException *****************" << endl;
00102 cerr << "******** MSGException caught (TestDemo) ********" << endl;
00103 cerr << "***************** MSGException *****************" << endl;
00104 cerr << endl;
00105 MSG("Fan", Msg::kError) << "This is a FATAL message\n";
00106 }
00107 }
|
|
|
Definition at line 48 of file TestDemo.cxx. References MsgStream::AddFormat(), MsgStream::AttachOStream(), MsgService::GetStream(), MsgService::Instance(), MsgStream::RemoveFormat(), MsgStream::SetFormat(), and MsgStream::SetLogLevel(). Referenced by main(). 00052 {
00053 // Get pointers to the message service and to the stream I want ("Str")
00054 // If you just want to use the defaults these line are not needed
00055 MsgService* msvc = MsgService::Instance();
00056 MsgStream* mstr = msvc->GetStream("Fan");
00057
00058 // Set the log level for the stream. If you just want the default
00059 // (kInfo) this line is not needed
00060 mstr->SetLogLevel(Msg::kDebug);
00061
00062 // Set where the output should go. These are the defaults so
00063 // techically this code fragment is not needed, however, "cerr" and
00064 // "cout" could be replaced with filenames if the user wants the
00065 // output in a text file
00066 mstr->AttachOStream(Msg::kVerbose, "cerr");
00067 mstr->AttachOStream(Msg::kInfo, "cout");
00068
00069 // If you don't like the default information that gets printed with
00070 // the messages you can change them like this:
00071
00072 // Set the format flags for verbose messages
00073 mstr->SetFormat(Msg::kVerbose, Msg::kPriority + Msg::kName);
00074
00075 // Add a format flag for warning messages
00076 mstr->AddFormat(Msg::kWarning, Msg::kTime);
00077
00078 // Lower a format flag for warning messages
00079 mstr->RemoveFormat(Msg::kWarning, Msg::kName);
00080 }
|
|
|
Definition at line 139 of file TestDemo.cxx. References fancyMessages(), fancyStuff(), manyMessageExample(), printStatistics(), and theBasics(). 00139 {
00140
00141 theBasics();
00142 fancyStuff();
00143 fancyMessages();
00144 manyMessageExample();
00145 printStatistics();
00146
00147 return EXIT_SUCCESS;
00148 }
|
|
|
Definition at line 111 of file TestDemo.cxx. References MSGSTREAM. Referenced by main(). 00112 {
00113 //======================================================================
00114 // Give an example where several messages all go to the same stream
00115 //======================================================================
00116 // If you have lots of messages going to the same stream you can do this:
00117 MsgStream *m1 = &MSGSTREAM("Mny", Msg::kError);
00118 (*m1) << " ===== *\n";
00119 (*m1) << "* Messages like this can save a little time and typing. *\n";
00120 (*m1) << "* However, notice that only one header gets printed! *\n";
00121 (*m1) << "* That's why I don't recommend using this for errors and *\n";
00122 (*m1) << "* warnings. *\n";
00123 (*m1) << "* ====================================================== *\n";
00124 }
|
|
|
Definition at line 128 of file TestDemo.cxx. References MsgService::Instance(), and MsgService::PrintStatistics(). Referenced by main(). 00129 {
00130 //======================================================================
00131 // Show how to print message service usage statistics
00132 //======================================================================
00133 // Print message service usage statistics
00134 MsgService::Instance()->PrintStatistics();
00135 }
|
|
|
Definition at line 20 of file TestDemo.cxx. References MSG. Referenced by main(). 00021 {
00022 //======================================================================
00023 // Send some messages to the stream -- this is basically all a
00024 // typical program should ever have to use. In the following the
00025 // "Bsx" would get replaced with the package prefix of the package
00026 // that was sending the message
00027 //======================================================================
00028 try {
00029 MSG("Bsx", Msg::kVerbose) << "This is a VERBOSE message\n";
00030 MSG("Bsx", Msg::kDebug) << "This is a DEBUG message\n";
00031 MSG("Bsx", Msg::kInfo) << "This is an INFO message\n";
00032 MSG("Bsx", Msg::kWarning) << "This is a WARNING message\n";
00033 MSG("Bsx", Msg::kError) << "This is an ERROR message\n";
00034 MSG("Bsx", Msg::kFatal) << "This is a FATAL message\n";
00035 }
00036 catch(MSGException) {
00037 cerr << endl << endl;
00038 cerr << "***************** MSGException *****************" << endl;
00039 cerr << "******** MSGException caught (TestDemo) ********" << endl;
00040 cerr << "***************** MSGException *****************" << endl;
00041 cerr << endl;
00042 MSG("Bsx", Msg::kError) << "This is a FATAL message\n";
00043 }
00044 }
|
1.3.9.1