Skip to content
Snippets Groups Projects
Commit 8f00e8f4 authored by Frank Winklmeier's avatar Frank Winklmeier
Browse files

FPTracker: remove SimpleLogger

The `SimpleLogger` class was only used to collect some "messages" but
they were never actually printed anywhere.
parent 7f288a6c
No related branches found
No related tags found
No related merge requests found
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef FPTRACKER_SIMPLELOGGER_H
#define FPTRACKER_SIMPLELOGGER_H
// Singleton class for collecting log messages
#include <vector>
#include <string>
#include <sstream>
namespace FPTracker
{
class SimpleLogger
{
public:
static SimpleLogger* getLogger();
void debug ( const std::string& );
void info ( const std::string& );
void warning ( const std::string& );
void error ( const std::string& );
void debug ( const std::ostringstream& );
void info ( const std::ostringstream& );
void warning ( const std::ostringstream& );
void error ( const std::ostringstream& );
std::vector< std::pair< unsigned int, std::string > > debugMsgs () const;
std::vector< std::pair< unsigned int, std::string > > infoMsgs () const;
std::vector< std::pair< unsigned int, std::string > > warningMsgs () const;
std::vector< std::pair< unsigned int, std::string > > errorMsgs () const;
std::string debug () const;
std::string info () const;
std::string warning () const;
std::string error () const;
void reset();
protected:
SimpleLogger();
private:
static SimpleLogger* m_instance;
unsigned int m_index;
std::vector< std::pair< unsigned int, std::string > > m_debugMsg;
std::vector< std::pair< unsigned int, std::string > > m_infoMsg;
std::vector< std::pair< unsigned int, std::string > > m_warningMsg;
std::vector< std::pair< unsigned int, std::string > > m_errorMsg;
};
}
#endif
......@@ -6,7 +6,6 @@
#include "FPTracker/STLHelpers.h"
#include "FPTracker/IParticle.h"
#include "FPTracker/IBeamElement.h"
#include "FPTracker/SimpleLogger.h"
#include "boost/shared_ptr.hpp"
#include <algorithm>
#include <cassert>
......@@ -99,7 +98,6 @@ namespace FPTracker{
particle.z(),
zPosNextElement() );
SimpleLogger::getLogger()->reset();
// pass the particle to succesive beam elements until either it goes out of aperture, or it reaches the end plane.
//cppcheck-suppress ignoredReturnValue
std::find_if(nextElement,
......
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
*/
#include "FPTracker/Collimator.h"
......@@ -7,7 +7,6 @@
#include "FPTracker/TransversePoint.h"
#include "FPTracker/beamlineXPosition.h"
#include "FPTracker/FPTrackerConstants.h"
#include "FPTracker/SimpleLogger.h"
#include <cmath>
#include <sstream>
#include <iostream>
......
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#include "FPTracker/SimpleLogger.h"
#include <algorithm>
namespace FPTracker
{
struct Consolidator
{
void operator()( const std::pair< unsigned int, std::string >& element)
{
m_msg += element.second;
}
std::string m_msg;
};
std::string consolidate(std::vector< std::pair< unsigned int, std::string > > msgs)
{
return std::for_each( msgs.begin(), msgs.end(), Consolidator() ).m_msg;
}
SimpleLogger* SimpleLogger::m_instance = 0;
SimpleLogger* SimpleLogger::getLogger()
{
if ( m_instance == 0 )
{
m_instance = new SimpleLogger;
}
return m_instance;
}
void SimpleLogger::debug (const std::string& msg)
{
m_debugMsg.push_back ( std::pair< unsigned int, std::string >( m_index, msg) );
++m_index;
}
void SimpleLogger::info (const std::string& msg)
{
m_infoMsg.push_back ( std::pair< unsigned int, std::string >( m_index, msg) );
++m_index;
}
void SimpleLogger::warning(const std::string& msg)
{
m_warningMsg.push_back( std::pair< unsigned int, std::string >( m_index, msg) );
++m_index;
}
void SimpleLogger::error (const std::string& msg)
{
m_errorMsg.push_back ( std::pair< unsigned int, std::string >( m_index, msg) );
++m_index;
}
void SimpleLogger::debug (const std::ostringstream& msg)
{
this->debug( msg.str() );
}
void SimpleLogger::info (const std::ostringstream& msg)
{
this->info( msg.str() );
}
void SimpleLogger::warning(const std::ostringstream& msg)
{
this->warning( msg.str() );
}
void SimpleLogger::error (const std::ostringstream& msg)
{
this->error( msg.str() );
}
std::vector< std::pair< unsigned int, std::string > >
SimpleLogger::debugMsgs () const { return m_debugMsg; }
std::vector< std::pair< unsigned int, std::string > >
SimpleLogger::infoMsgs () const { return m_infoMsg; }
std::vector< std::pair< unsigned int, std::string > >
SimpleLogger::warningMsgs() const { return m_warningMsg; }
std::vector< std::pair< unsigned int, std::string > >
SimpleLogger::errorMsgs () const { return m_errorMsg; }
std::string
SimpleLogger::debug () const { return consolidate(m_debugMsg); }
std::string
SimpleLogger::info () const { return consolidate(m_infoMsg); }
std::string
SimpleLogger::warning() const { return consolidate(m_warningMsg); }
std::string
SimpleLogger::error () const { return consolidate(m_errorMsg); }
void
SimpleLogger::reset()
{
m_index = 0;
m_debugMsg.erase ( m_debugMsg.begin(), m_debugMsg.end() );
m_infoMsg.erase ( m_infoMsg.begin(), m_infoMsg.end() );
m_warningMsg.erase( m_warningMsg.begin(), m_warningMsg.end() );
m_errorMsg.erase ( m_errorMsg.begin(), m_errorMsg.end() );
}
SimpleLogger::SimpleLogger():m_index(0){}
}
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
*/
#include "FPTracker/getAlfaMagnetConfigFiles.h"
#include "FPTracker/getConfigFile.h"
#include "FPTracker/SimpleLogger.h"
#include "../src/openFile.tpl"
#include <sstream>
#include <stdexcept>
......@@ -15,13 +14,7 @@ namespace FPTracker{
boost::shared_ptr<std::ifstream> getAlfaMagnetConfigFiles(const std::string& dir, const Side& side)
{
std::string fn = (side == beam1) ? "alfaTwiss1.txt":"alfaTwiss2.txt";
std::ostringstream ost;
ost<<"Using ALFA twiss file "<<fn<<'\n';
SimpleLogger* logger = SimpleLogger::getLogger();
logger->info( ost );
return getConfigFile( dir, fn );
}
}
......
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
*/
#include "FPTracker/getMagnetConfigFiles.h"
#include "FPTracker/getConfigFile.h"
#include "FPTracker/SimpleLogger.h"
#include "../src/openFile.tpl"
#include <sstream>
#include <iostream>
......@@ -51,12 +50,7 @@ namespace FPTracker{
boost::shared_ptr<std::ifstream> getMagnetConfigFiles(const std::string& dir, int IP, int magVer, const Side& side)
{
std::ostringstream ost;
ost<<determineMagnetConfigFileName(IP, side, magVer)<<'\n';
SimpleLogger::getLogger()->info(ost);
return getConfigFile( dir, determineMagnetConfigFileName(IP, side, magVer) );
}
}
......
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
*/
#include "FPTracker/readConfigData.h"
#include "FPTracker/ConfigData.h"
#include "FPTracker/SimpleLogger.h"
#include "boost/lexical_cast.hpp"
#include "boost/tokenizer.hpp"
#include <fstream>
......@@ -32,10 +31,6 @@ namespace FPTracker{
m_errors = true;
ok = false;
std::ostringstream ost;
ost<<"error converting "<< s <<'\n';
SimpleLogger::getLogger()->info(ost);
m_notConverted.push_back(s);
}
......@@ -103,8 +98,6 @@ namespace FPTracker{
}
SimpleLogger::getLogger()->info( ost );
return !vs.errors();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment