source: JEM-EUSO/esaf_cc_at_lal/packages/common/base/src/EsafMsgSource.cc @ 114

Last change on this file since 114 was 114, checked in by moretto, 11 years ago

actual version of ESAF at CCin2p3

File size: 2.7 KB
Line 
1// $Id: EsafMsgSource.cc 2800 2008-02-11 14:16:18Z naumov $
2// M. Pallavicini created Sep, 24 2004
3
4/*****************************************************************************
5 * ESAF: Euso Simulation and Analysis Framework                              *
6 *                                                                           *
7 *  Id: EsafMsgSource                                                        *
8 *  Package: Optics                                                          *
9 *  Coordinator: Marco.Pallavicini                                           *
10 *                                                                           *
11 *****************************************************************************/
12
13//_____________________________________________________________________________
14// 
15//  ESAF Message Source
16//  ===================
17//
18//  Each class that wants to send messages must inherit from this one
19//
20//  Two ways to send a message:
21// 
22//  Using a stream
23//  examples (equivalent):
24//     Msg(EsafMsg::Warning) << "my text" << MsgDispatch;
25//  or
26//     Msg(EsafMsg::Warning) << "my text";
27//     Dispatch();
28//
29//  or using printf like syntax:
30//  example:
31//     MsgForm( EsafMsg::Severity, "msg with printf formatting", var1, var2...);
32// 
33//  The messages are dispatched on screen and log file according to the default
34//  values specified by the configuration files
35//
36//BEGIN_HTML <!--
37/* -->
38<!--*/
39// -->END_HTML
40//
41
42#include "EsafMsgSource.hh"
43#include "TClass.h"
44#include "TString.h"
45#include <iostream>
46#include <list>
47#include <TMath.h>
48using namespace std;
49ClassImp(EsafMsgSource) 
50
51//______________________________________________________________________________
52EsafMsgSource::EsafMsgSource() {
53    //
54        // ctor
55        //
56
57        fMsg.Clear();
58}
59
60//______________________________________________________________________________
61EsafMsgSource::EsafMsgSource( const EsafMsgSource& ) {
62    //
63    // copy ctor
64    //
65   
66}
67
68//______________________________________________________________________________
69EsafMsg& EsafMsgSource::Msg(EsafMsg::MsgSeverity s) const {
70    //
71        // Prepare a new message and returns it
72    //
73
74    if ( fMsg.GetSender() == "None") fMsg.SetSender(IsA()->GetName());
75        fMsg.SetSeverity(s); 
76        return fMsg;
77}
78
79const size_t kMaxBufSize = 4096;
80
81//______________________________________________________________________________
82void EsafMsgSource::MsgForm(EsafMsg::MsgSeverity s, const char *va_(fmt), ...) const {
83    //
84    // Prepare and send a message with printf syntax
85    //
86
87    static char b[kMaxBufSize];
88
89    va_list ap;
90    va_start(ap,fmt);
91    vsnprintf(b,kMaxBufSize,fmt,ap); // There is no boundary check here. (bug)
92    va_end(ap);
93    Msg(s) << b << MsgDispatch;
94}
95
Note: See TracBrowser for help on using the repository browser.