Commit 3fb36f48 authored by Stezowski Olivier's avatar Stezowski Olivier
Browse files

new log message including indentation

git-svn-id: svn+ssh://anonsvn.in2p3.fr/agata/gammaware/trunk@1312 c3abf467-7ff2-0310-b516-c5fb849bdde0
parent 7ffdcf68
./ AFC_ 0
# /path/to/the/adf/file file_pattern starting_number
# means start try to read
# ./AFC_0000.adf .... ./AFC_XYZT.adf
# until a non-existing file in the chain is reached
......@@ -72,6 +72,7 @@
#include "TTimer.h"
#endif
#include "DFAgent.h"
#include "AgataKeyFactory.h"
using namespace ADF;
......@@ -89,8 +90,8 @@ Bool_t EventPSAWatcher::SetTrigger( ADF::DFTrigger *trigger )
FactoryItem i_asked, k_defined, f_defined;
i_asked.SetItem("Agata","data:psa",Version());
k_defined = ConfAgent::theGlobalAgent()->WhichKnownKey (i_asked,i_asked);
f_defined = ConfAgent::theGlobalAgent()->WhichKnownFrame (i_asked,i_asked);
k_defined = ConfAgent::theGlobalAgent()->GetDFAgent()->WhichKnownKey (i_asked,i_asked);
f_defined = ConfAgent::theGlobalAgent()->GetDFAgent()->WhichKnownFrame (i_asked,i_asked);
Frame *f = FrameFactory::New(k_defined,f_defined);
if ( f ) { // it exists
......
......@@ -92,7 +92,7 @@
cout << " - to watch one selected actor " << endl;
cout << " .x OnlineWatchersLLP.C+ or .x OnlineWatchersLLP.C+(new TFile(\"MySpectra.root\",\"UPDATE\"))" << endl;
cout << " - to watch simultaneously all the actors " << endl;
cout << " .x OnlineWatchersLLP.C+(OxO,true) or .x OnlineWatchersLLP.C+(new TFile(\"MySpectra.root\",\"UPDATE\"),true)" << endl;
cout << " .x OnlineWatchersLLP.C+(0x0,true) or .x OnlineWatchersLLP.C+(new TFile(\"MySpectra.root\",\"UPDATE\"),true)" << endl;
cout << " To start online (Global Level) Watchers : " << endl;
cout << " .x OnlineWatchersGLP.C+ or .x OnlineWatchersGLP.C+(new TFile(\"MySpectra.root\",\"UPDATE\"))" << endl;
cout << " Then start the watching from the ROOT Browser " << endl << endl;
......
......@@ -112,12 +112,12 @@ template <typename Prod_actor>
Bool_t WatcherServer<Prod_actor>::Init()
{
UInt_t err = 0u;
fLog.GetProcessMethod() = "Init";
fLog.SetProcessMethod("Init");
// just in case a actor forget to call it and it is required.
NarvalInterface::process_config(fPathProd.data(),&err);
if ( err > 0u ) {
fLog << warning << " in NarvalInterface::process_config " << dolog;
fLog << warning << " in NarvalInterface::process_config " << nline;
}
err = 0u;
......
#include "TObject.h"
#include "LogMessage.h"
class TestLOG_0
{
protected:
//! send meesages to the log system
LogMessage fLog;
public:
TestLOG_0() : fLog("TestLOG_0") {;}
virtual ~TestLOG_0()
{;}
void ToLog_0();
};
void TestLOG_0::ToLog_0()
{
Int_t i = 0;
// set the method and open a log ticket
fLog.SetProcessMethod("ToLog_0");
// ... do something
fLog << info << i << " set to 0 " << nline;
// ... do something
fLog << dolog;
}
class TestLOG_1 : public TestLOG_0
{
public:
TestLOG_1() { fLog.GetProcessName() = "TestLOG_1" ; }
virtual ~TestLOG_1()
{;}
virtual void ToLog_1();
};
void TestLOG_1::ToLog_1()
{
Int_t i = 1;
// set the method and open a log ticket
fLog.SetProcessMethod("ToLog_1");
TestLOG_0::ToLog_0();
// ... do something
fLog << error << i << " cannot be set to 1 " << nline;
// ... do something
// sent all the collected messages to the LogCollector
fLog << dolog;
}
class TestLOG_2 : public TestLOG_1
{
public:
TestLOG_2() { fLog.GetProcessName() = "TestLOG_2" ; }
virtual ~TestLOG_2()
{;}
virtual void ToLog_2();
};
void TestLOG_2::ToLog_2()
{
Int_t i = 2;
// set the method and open a log ticket
fLog.SetProcessMethod("ToLog_2");
TestLOG_1::ToLog_1();
// ... do something
fLog.SetLevel(LogMessage::kWarning,1);
fLog << i << " cannot be set to 2 " << nline;
fLog.SetLevel(LogMessage::kInfo,0);
// ... do something
// sent all the collected messages to the LogCollector
fLog << dolog;
}
class TestLOG_3 : public TestLOG_2
{
public:
TestLOG_3() { fLog.GetProcessName() = "TestLOG_3" ; }
virtual ~TestLOG_3()
{;}
virtual void ToLog_3();
};
void TestLOG_3::ToLog_3()
{
Int_t i = 3;
// set the method and open a log ticket
fLog.SetProcessMethod("ToLog_3");
TestLOG_2::ToLog_2();
// ... do something
fLog << i << " cannot be set to 3 " << nline;
// ... do something
// sent all the collected messages to the LogCollector
fLog << dolog;
}
#include "LogCollector.h"
#include "CentralLog.h"
void TestLOG()
{
TestLOG_0 lev0; TestLOG_1 lev1; TestLOG_2 lev2; TestLOG_3 lev3;
printf("\n*************** Log cout, not depth *************** \n");
LogMessage::gkMaxDepth = 1;
// log messages, no depth
lev0.ToLog_0();
// log messages, one depth's call
lev1.ToLog_1();
// log messages, two depth' calls
lev2.ToLog_2();
// log messages, three depth' calls
lev3.ToLog_3();
printf("\n*************** Log cout, and depth *************** \n");
LogMessage::gkMaxDepth = 5;
// log messages, no depth
lev0.ToLog_0();
// log messages, one depth's call
lev1.ToLog_1();
// log messages, two depth' calls
lev2.ToLog_2();
// log messages, three depth' calls
lev3.ToLog_3();
// A log collector is created to collector logs in a file
// WARNING !! the user should notify if the new collector is owned by teh CentralLog with
// OStreamCollector("TEST.log",true)
// which is the default behavior. In this case CentralLog deletes the Collector
// if set to false, the user should take of deleting the collector
OStreamCollector *test_collector = new OStreamCollector("TestLOG.log");
CentralLog::theCentralLog()->Add( test_collector ) ;
CentralLog::theCentralLog()->ChangeCollector(std::string("TestLOG.log"));
printf("\n*************** Log file, and depth *************** \n");
// log messages, no depth
lev0.ToLog_0();
// log messages, one depth's call
lev1.ToLog_1();
// log messages, two depth' calls
lev2.ToLog_2();
// log messages, three depth' calls
lev3.ToLog_3();
printf("\n************** Log all to black hole ************** \n");
// messages are now sent to a black hole !
CentralLog::theCentralLog()->ChangeCollector(std::string("NULL"));
}
{
/*
rootlogon.C to set the Macro and include path to the GammaWare package.
The system has to be properly built i.e.
LD_LIBRARY_PATH set to the directory where gw.rootmap is set.
O. Stézowski
*/
// ---> GammaWare PART /////////////////////////
printf("******************************************************************** \n") ;
printf(" Messages from Load.C \n") ;
printf("******************************************************************** \n") ;
// to add to ROOT the Gw path to look for macros
TString tmp, macroPATH;
macroPATH = gROOT->GetMacroPath(); tmp = Gw::Env::GetPath("MacrosPath");
if ( macroPATH.Contains(tmp.Data()) == false ) {
printf("- Add %s to the macros path \n",tmp.Data());
tmp += ":";
macroPATH.Prepend(tmp.Data()); gROOT->SetMacroPath(macroPATH.Data());
}
// add GammaWare include path to ROOT for compilation
tmp = Gw::Env::GetPath("IncludePath"); printf("- Add %s to the include path \n",tmp.Data());
tmp.Prepend(" .include ");
gROOT->ProcessLine(tmp.Data());
}
......@@ -2,7 +2,7 @@
# This is a begin of the ADF configuration record
# Option is Init. It means the Agent is reset before being initialised
#
#////ADF::ConfAgent_beg//// Agata 1 Init
#////ADF::ConfAgent_beg//// Agata 0 Init
#
#
Endian: kLittle
......@@ -34,7 +34,7 @@ AutoConf: Agata conf:global 2 0 Agata conf:global 0 0
#
#////ADF::ConfAgent_end////
#
#////ADF::AgataKeyFactory_beg//// Init
#////ADF::AgataKeyFactory_beg//// - 1 Init
#
# Definition of the message part for Agata like Keys
#
......@@ -76,7 +76,8 @@ data:ranc0 0xFA0201A0 0xFFFFFFFF
data:ranc1 0xFA0201A1 0xFFFFFFFF
data:ranc2 0xFA0201A2 0xFFFFFFFF
meta 0xFA001100 0xFF00FF00
meta:vertex 0xFA011100 0xFFFFFFFF
meta:sync 0xFA011100 0xFFFFFFFF
meta:vertex 0xFA011101 0xFFFFFFFF
#
#////ADF::AgataKeyFactory_end////
#
......
......@@ -28,17 +28,6 @@
#include "Env.h"
#endif
std::string ADF::BeginOfRecord(const char *class_name)
{
std::string bor = "#////"; bor += class_name; bor += "_beg////"; return bor;
}
std::string ADF::EndOfRecord(const char *class_name)
{
std::string eor = "#////"; eor += class_name; eor += "_end////"; return eor;
}
std::string ADF::GetPathToConfFile()
{
std::string tmp;
......
......@@ -110,9 +110,6 @@ const char kLong64_t[] = "L";
const char kFloat_t[] = "F";
const char kDouble_t[] = "D";
std::string BeginOfRecord(const char *class_name);
std::string EndOfRecord(const char *class_name);
std::string GetPathToConfFile();
}
......
......@@ -50,7 +50,7 @@ using namespace ADF;
AgataFrameFactory::AgataFrameFactory(): AFrameFactory<AgataFrameFactory>("Agata")
{
// set reference to this method for log system
fLog.GetProcessName() = "AgataFrameFactory"; fLog.GetProcessMethod() = "AgataFrameFactory()";
fLog.GetProcessName() = "AgataFrameFactory"; fLog.SetProcessMethod("AgataFrameFactory()");
AgataKeyFactory *fact = AKeyFactory<AgataKeyFactory>::theFactory();
......@@ -64,9 +64,11 @@ AgataFrameFactory::AgataFrameFactory(): AFrameFactory<AgataFrameFactory>("Agata"
SetPrimaryKey(a_primary_key);
delete a_primary_key;
}
else { fLog << error << " Cannot get an AgataKey(1,0) from AgataKeyFactory" << dolog; }
else { fLog << error << " Cannot get an AgataKey(1,0) from AgataKeyFactory" << nline; }
}
else { fLog << error << " AgataKeyFactory does not exist" << dolog; }
else { fLog << error << " AgataKeyFactory does not exist" << nline; }
fLog << dolog;
}
......
......@@ -128,9 +128,9 @@ Key *AgataKeyFactory::NewImp(const Char_t *keyname, Version version)
return key;
}
void AgataKeyFactory::ProcessLine(const std::string &aline)
Bool_t AgataKeyFactory::ProcessLine(const std::string &aline)
{
std::string tmp; UInt_t ui1, ui2;
std::string tmp; UInt_t ui1, ui2; Bool_t ok_decode = true;
std::istringstream decode(aline);
// just to be sure ...
......@@ -145,7 +145,11 @@ void AgataKeyFactory::ProcessLine(const std::string &aline)
fMessageTable[keytype] = tmpp;
}
else
ok_decode = false;
// printf("TABLE SIZE %d\n",fMessageTable.size());
return ok_decode;
}
......@@ -163,79 +167,29 @@ const char *AgataKeyFactory::GetMessage(UInt_t message)
return st.c_str();
}
Bool_t AgataKeyFactory::DoConfigure(std::istream &in)
Bool_t AgataKeyFactory::DoConfigure (std::ostream & out)
{
// set reference to this method for log system
fLog.GetProcessMethod() = "DoConfigure(istream)";
std::string tmp, option,
bor=BeginOfRecord("ADF::AgataKeyFactory"),eor=EndOfRecord("ADF::AgataKeyFactory");
Bool_t is_a_record = false, do_process = false;
// add a start record
AddRecord(out,'b');
// look for a configuation record for this class
getline(in,tmp);
tmp += " ";
while ( in.good() && !in.eof() ) { // read input stream line by line
if ( tmp[0] == '#' ) {
// this is a start of record statement for that class
if ( tmp.find(bor) == 0 ) {
// get option
option = tmp.substr(bor.length()+1);
if ( option.find("Init") != std::string::npos)
Reset();
// now all line are processed by ProcessLine
do_process = is_a_record = true;
}
// this is a end of record statement for that class
if ( tmp.find(eor) == 0 ) {
do_process = false;
}
getline(in,tmp);
tmp += " ";
continue;
} // this line is a comment
if (do_process)
ProcessLine(tmp);
// do not forget to add tmp += " ";
getline(in,tmp);
tmp += " ";
}
// message to the log in case something happened
if ( is_a_record )
fLog << " Message table initialised with option: " << option << dolog;
return is_a_record;
}
Bool_t AgataKeyFactory::DoConfigure(std::ostream &out)
{
// set reference to this method for log system
fLog.GetProcessMethod() = "DoConfigure(ostream)";
std::string tmp, option,
bor=BeginOfRecord("ADF::AgataKeyFactory"),eor=EndOfRecord("ADF::AgataKeyFactory");
if ( fMessageTable.size() > 0 ) { // default message type must be loaded
out << bor << " Init \n";
// iterator on the map
std::map<std::string,std::pair<UInt_t,UInt_t> >::iterator im;
for (im = fMessageTable.begin() ; im != fMessageTable.end() ; im++ ) {
out << im->first << "\t\t"
<< std::hex << im->second.first << "\t" << im->second.second << std::dec << " \n" ;
<< std::hex << im->second.first << "\t" << im->second.second << std::dec << " \n" ;
}
out << eor << " \n";
}
// else { printf("Should not be empty \n "); }
}
// add an end of record
AddRecord(out,'e');
return true;
return out.good();
}
......@@ -27,10 +27,12 @@
#ifndef ADF_KeyFactory
#include "KeyFactory.h"
#endif
#ifndef ADF_Key
#include "Key.h"
#endif
#ifndef ADF_DotConf
#include "DotConf.h"
#endif
#include <iostream>
#include <string>
......@@ -168,8 +170,13 @@ private:
private:
AgataKeyFactory () : AKeyFactory<AgataKeyFactory>("Agata"), fMessageTable()
{ fLog.GetProcessName() = "AgataKeyFactory"; }
virtual ~AgataKeyFactory () { ; }
{
fLog.GetProcessName() = "ADF::AgataKeyFactory";
SetRID("ADF::AgataKeyFactory");
SetWithRecord(true);
}
virtual ~AgataKeyFactory ()
{ ; }
protected:
//! Ask this factory for a new AgataKeyFactory
......@@ -178,10 +185,11 @@ protected:
virtual Key *NewImp(const Char_t *, Version);
//! During configuration, process a single line
void ProcessLine(const std::string &);
Bool_t ProcessLine(const std::string &);
//! Reset the table
void Reset() { fMessageTable.clear(); }
void Reset(const Char_t * = "")
{ fMessageTable.clear(); }
public:
//! Agata files are always little endian !!
virtual void SetEndian(BaseBuffer::EEndian)
......@@ -189,17 +197,16 @@ public:
//! to get the message part as a string
const Char_t *GetMessage(UInt_t);
//!
//! write the message table
virtual Bool_t DoConfigure(std::ostream &) ;
//!
virtual Bool_t DoConfigure(std::istream &) ;
virtual Bool_t DoConfigure(std::istream &in)
{ return DotConf::DoConfigure(in); }
};
// AgataKeyFactory inline members //////////////////////////////////////////////////////
} // namespace ADF
#endif
......
......@@ -43,7 +43,7 @@ BasicAFC::BasicAFC() :
GetFrameIO().SetName("BasicAFC");
// to be sure unknown frames are written in the ouput
GetConfAgent()->SetModel(ConfAgent::kSafe);
GetFrameIO().SetModel(ConfAgent::kSafe);
// to protect readings in the source of frames
fEndOfFrames.SetModeIO(ConfAgent::kWrite);
......@@ -129,7 +129,7 @@ UInt_t BasicAFC::ProcessBlock (ADF::FrameBlock &in)
void BasicAFC::process_initialise (UInt_t *error_code)
{
*error_code = 0;
Log.ClearMessage(); Log.GetProcessMethod() = "process_initialise";
Log.ClearMessage(); Log.SetProcessMethod("process_initialise");
// read an input file to get the base filename and the path
std::string conffile = GetConfPath();
......@@ -161,12 +161,13 @@ void BasicAFC::process_initialise (UInt_t *error_code)
void BasicAFC::process_reset (UInt_t *error_code)
{
*error_code = 0;
Log.ClearMessage(); Log.GetProcessMethod() = "process_reset";
Log.ClearMessage(); Log.SetProcessMethod("process_reset");
if ( fCurrentFile )
::fclose(fCurrentFile);
GetFrameIO().Print( Log() );
Log << dolog;
}
......
......@@ -42,7 +42,7 @@ BasicAFP::BasicAFP():
Log.GetProcessName() = "BasicAFP"; GetFrameIO().SetName("BasicAFP");
// to be sure unknown frames are written in the ouput
GetConfAgent()->SetModel(ConfAgent::kSafe);
GetFrameIO().SetModel(ConfAgent::kSafe);
// to protect writings in the source of frames
fSourceOfFrames.SetModeIO(ConfAgent::kRead);
......@@ -130,7 +130,7 @@ UInt_t BasicAFP::ProcessBlock(ADF::FrameBlock &out)
void BasicAFP::process_initialise (UInt_t *error_code)
{
*error_code = 0u;
Log.ClearMessage(); Log.GetProcessMethod() = "process_initialise";
Log.ClearMessage(); Log.SetProcessMethod("process_initialise");
// read an input file to get the base filename and the path
std::string conffile
......@@ -163,12 +163,13 @@ void BasicAFP::process_initialise (UInt_t *error_code)
void BasicAFP::process_reset (UInt_t *error_code)
{
*error_code = 0u;
Log.ClearMessage(); Log.GetProcessMethod() = "process_reset";
Log.ClearMessage(); Log.SetProcessMethod("process_reset");
if ( fCurrentFile )
::fclose(fCurrentFile);
GetFrameIO().Print( Log() );
Log << dolog;
}
/*
......
This diff is collapsed.
/***************************************************************************
* Copyright (C) 2004 by Olivier Stezowski *
* stezow(AT)ipnl.in2p3.fr *
* stezow(AT)ipnl.in2p3.fr *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
......@@ -13,7 +13,7 @@
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* aLong_t with this program; if not, write to the *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
......@@ -23,163 +23,81 @@
#ifndef ADF_ConfAgent
#define ADF_ConfAgent
#ifndef ADF_FactoryItem
#include "FactoryItem.h"
#endif
#ifndef ADF_BufferIO
#include "BufferIO.h"
#endif
#ifndef _LogMessage
#include "LogMessage.h"
#ifndef ADF_DotConf
#include "DotConf.h"
#endif