CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ELcollected.cc
Go to the documentation of this file.
1 // ----------------------------------------------------------------------
2 //
3 // ELcollected.cc
4 //
5 // History:
6 // 07-Jun-2000 WEB Reflect consolidation of ELdestination/X and of
7 // ELoutput/X; consolidate ELcollected/X
8 // 15-Sep-2000 MF Corrected bug: copy constructor needs to set sender
9 // based on a clone() of *sender, not a bit copy, since
10 // the whole reasoning was to protect against the user's
11 // objects going out of scope.
12 // 4-Apr-2001 MF Loginc to ignore ore respond to modules, using base
13 // method thisShouldBeIgnored().
14 //
15 // ----------------------------------------------------------------------
16 
21 
22 #include <sstream>
23 
24 // Possible Traces:
25 //#define ELcollectedCONSTRUCTOR_TRACE
26 //#define ELcollectedTRACE_LOG
27 //#define ELcollected_EMIT_TRACE
28 
29 namespace edm {
30 namespace service {
31 
32 
33 // ----------------------------------------------------------------------
34 // Constructors:
35 // ----------------------------------------------------------------------
36 
38 : ELoutput()
39 , sender ( snd.clone() )
40 {
41 
42  #ifdef ELcollectedCONSTRUCTOR_TRACE
43  std::cout << "Constructor for ELcollected(ELsender)\n";
44  #endif
45 
46  // Unlike ELoutput, we do not emit Error Log established message.
47 
48 } // ELcollected()
49 
50 
52 : ELoutput( orig )
53 , sender ( orig.sender->clone() ) // $$ mf 9/15/00
54 {
55 
56  #ifdef ELcollectedCONSTRUCTOR_TRACE
57  std::cout << "Copy constructor for ELcollected\n";
58  #endif
59 
63  ignoreThese = orig.ignoreThese;
64 
65 } // ELcollected()
66 
67 
69 
70  #ifdef ELcollectedCONSTRUCTOR_TRACE
71  std::cout << "Destructor for ELcollected)\n";
72  #endif
73 } // ~ELcollected()
74 
75 
76 
77 // ----------------------------------------------------------------------
78 // Methods invoked by the ELadministrator:
79 // ----------------------------------------------------------------------
80 
83 
84  return new ELcollected( *this );
85 
86 } // clone()
87 
88 
89 // Remainder are from base class.
90 
91 // =======
92 // intoBuf
93 // =======
94 
95 void ELcollected::intoBuf( const ELstring & s ) {
96 
97  buf += s;
98  buf += '\0';
99 
100 } // intoBuf();
101 
102 
103 // ========
104 // emitXid
105 // ========
106 
107 void ELcollected::emitXid( const ELextendedID & xid ) {
108 
109  buf = "";
110 
111  intoBuf ( xid.process );
112  intoBuf ( xid.module );
113  intoBuf ( xid.subroutine );
114  intoBuf ( xid.id );
115  std::ostringstream ost;
116  ost << xid.severity.getLevel();
117  intoBuf ( ost.str() );
118 
119 } // emitXid
120 
121 
122 // =====
123 // emit
124 // =====
125 
126 void ELcollected::emitToken( const ELstring & s, bool nl ) {
127 
128  #ifdef ELcollected_EMIT_TRACE
129  std::cout << "[][][] in emit: s.length() " << s.length() << "\n";
130  #endif
131 
132  // A forced newline is something that needs to be transmitted.
133  // We shall insert it as its own item.
134 
135  if (s.length() == 0) {
136  if ( nl ) {
137  intoBuf( newline );
138  charsOnLine = 0;
139  }
140  return;
141  }
142 
143  // Setting up for indentation if you start with a nweline, or if the length
144  // exceeds column 80, is not done here, it is done on the server.
145 
146  #ifdef ELcollected_EMIT_TRACE
147  std::cout << "[][][] in emit: about to << s to buf: " << s << " \n";
148  #endif
149 
150  // Place the item into the buffer
151 
152  intoBuf (s);
153 
154  // Accounting for trailing \n is done at the server.
155 
156  // A forced trailing newline is something that needs to be transmitted.
157  // We shall insert it as its own item.
158 
159  if ( nl ) {
160  intoBuf (newline);
161  }
162 
163  #ifdef ELcollected_EMIT_TRACE
164  std::cout << "[][][] in emit: completed \n";
165  #endif
166 
167 } // emitToken()
168 
169 
170 
171 // ====
172 // log
173 // ====
174 
176 
177  #ifdef ELcollectedTRACE_LOG
178  std::cout << " =:=:=: Log to an ELcollected \n";
179  #endif
180 
181  xid = msg.xid(); // Save the xid.
182 
183  // See if this message is to be acted upon, and add it to limits table
184  // if it was not already present:
185  //
186  if ( msg.xid().severity < threshold ) return false;
187  if ( thisShouldBeIgnored(xid.module) ) return false;
188  if ( ! limits.add( msg.xid() ) ) return false;
189 
190  #ifdef ELcollectedTRACE_LOG
191  std::cout << " =:=:=: Limits table work done \n";
192  #endif
193 
194  // start the buffer with the xid
195 
196  emitXid (xid);
197 
198  //
199 
200  #ifdef ELcollectedTRACE_LOG
201  std::cout << " =:=:=: xid emitted \n";
202  #endif
203 
204  // Provide the context information. The server side will use this to prime
205  // its special context supplier. We will send over all three types of
206  // context, even though probably only 1 or 2 will be needed.
207 
209  getContextSupplier().summaryContext());
211  getContextSupplier().context());
213  getContextSupplier().fullContext());
214 
215  #ifdef ELcollectedTRACE_LOG
216  std::cout << " =:=:=: Context done: \n";
217  #endif
218 
219  // No prologue separate from what the server will issue.
220 
221  // No serial number of message separate from what the server will issue.
222 
223  // collected each item in the message:
224  //
225  if ( wantText ) {
226  ELlist_string::const_iterator it;
227  for ( it = msg.items().begin(); it != msg.items().end(); ++it ) {
228  #ifdef ELcollectedTRACE_LOG
229  std::cout << " =:=:=: Item: " << *it <<"\n";
230  #endif
231  emitToken( *it );
232  }
233  }
234 
235  // DO NOT Provide further identification such as module and subroutine;
236  // the server side will provide that using the xid you have sent it, if
237  // the server side user wants it.
238 
239  // DO NOT provide time stamp; it would duplicate server's stamp!
240 
241  // Provide traceback information:
242  //
243  if ( msg.xid().severity >= traceThreshold ) {
244  emitToken( ELstring("\n")
245  + ELadministrator::instance()->getContextSupplier().traceRoutine()
246  , true );
247  }
248  else { //else statement added JV:1
249  emitToken( "", true );
250  }
251  #ifdef ELcollectedTRACE_LOG
252  std::cout << " =:=:=: Trace routine done: \n";
253  #endif
254 
255  // Message has been fully processed through emit; now put in an extra
256  // zero, and send out the buffer.
257  //
258 
259  buf += char(0);
260  int nbuf = buf.length();
261 
262  sender->send ( nbuf, buf.data() );
263 
264  #ifdef ELcollectedTRACE_LOG
265  std::cout << " =:=:=: log(msg) done: \n";
266  #endif
267 
268  return true;
269 
270 } // log()
271 
272 
273 // ----------------------------------------------------------------------
274 
275 
276 } // end of namespace service
277 } // end of namespace edm
278 
ELseverityLevel traceThreshold
ELseverityLevel severity
Definition: ELextendedID.h:36
boost::shared_ptr< ELsender > sender
Definition: ELcollected.h:136
virtual ELcollected * clone() const
Definition: ELcollected.cc:82
virtual bool thisShouldBeIgnored(const ELstring &s) const
void emitToken(const ELstring &s, bool nl=false)
Definition: ELcollected.cc:126
edm::ELextendedID xid
Definition: ELoutput.h:115
void intoBuf(const ELstring &s)
Definition: ELcollected.cc:95
const ELextendedID & xid() const
Definition: ErrorObj.cc:146
bool add(const ELextendedID &xid)
void emitXid(const ELextendedID &xid)
Definition: ELcollected.cc:107
ELstring subroutine
Definition: ELextendedID.h:38
virtual bool log(const edm::ErrorObj &msg)
Definition: ELcollected.cc:175
const ELlist_string & items() const
Definition: ErrorObj.cc:149
static ELadministrator * instance()
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
tuple cout
Definition: gather_cfg.py:121
ELcollected(const ELsender &sender)
Definition: ELcollected.cc:37
std::string ELstring
Definition: ELstring.h:26