SLIC  6.1.1
Simulation for the Linear Collider (SLIC) - Geant4 simulation application
LogMessenger.cc
Go to the documentation of this file.
1 // $Id: LogMessenger.cc,v 1.13 2013-06-26 01:57:02 jeremy Exp $
2 
3 // SLIC
4 #include "LogMessenger.hh"
5 #include "LogStream.hh"
6 
7 // LCDD
8 #include "lcdd/util/StringUtil.hh"
9 
10 // Geant4
11 #include "G4UIcmdWithAnInteger.hh"
12 #include "G4UIcmdWithAString.hh"
13 #include "G4UIdirectory.hh"
14 
15 namespace slic {
17  m_logStream(logger) {
19 }
20 
22  ;
23 }
24 
25 void LogMessenger::SetNewValue(G4UIcommand* cmd, G4String newVals) {
26  if (cmd == m_setLevelCmd) {
27  m_logStream->setOutputLevel((LOG::ELevel) G4UIcmdWithAnInteger::GetNewIntValue(newVals));
28  } else if (cmd == m_fileCmd) {
29  m_logStream->setOutputFile(newVals);
30  }
31 }
32 
34  m_loggerDir = new G4UIdirectory(std::string("/log/" + m_logStream->getName() + "/").c_str());
35  m_loggerDir->SetGuidance(std::string("Commands for the logger " + m_logStream->getName()).c_str());
36 
37  m_setLevelCmd = new G4UIcmdWithAnInteger(std::string("/log/" + m_logStream->getName() + "/setLogLevel").c_str(), this);
38  m_setLevelCmd->SetParameterName("logLevel", false);
39  std::string range = "logLevel >= 0 && logLevel < " + StringUtil::toString(LOG::nlevels);
40  m_setLevelCmd->SetRange(range.c_str());
41  m_setLevelCmd->SetGuidance("Set the log level.");
42 
43  m_fileCmd = new G4UIcmdWithAString(std::string("/log/" + m_logStream->getName() + "/setLogFile").c_str(), this);
44  m_fileCmd->SetParameterName("file", false);
45  m_fileCmd->SetGuidance("Set the output file for this logger.");
46 }
47 }
G4UIdirectory * m_loggerDir
Definition: LogMessenger.hh:54
LogMessenger(LogStream *logstream)
Definition: LogMessenger.cc:16
G4UIcmdWithAnInteger * m_setLevelCmd
Definition: LogMessenger.hh:52
G4UIcmdWithAString * m_fileCmd
Definition: LogMessenger.hh:53
void SetNewValue(G4UIcommand *command, G4String newValues)
Definition: LogMessenger.cc:25
virtual ~LogMessenger()
Definition: LogMessenger.cc:21
LogStream * m_logStream
Definition: LogMessenger.hh:50
A class for streaming messages to a log.
Definition: LogStream.hh:71
void setOutputLevel(const LOG::ELevel &outputLevel)
Definition: LogStream.hh:135
const std::string & getName() const
Definition: LogStream.hh:111
void setOutputFile(const std::string &file)
Definition: LogStream.hh:220
ELevel
Definition: LogStream.hh:32
@ nlevels
Definition: LogStream.hh:33