43 G4String::size_type prev_pos = 0,
pos = 0;
44 while((pos = input.find(separator, pos)) != G4String::npos)
46 G4String substr(input.substr(prev_pos, pos - prev_pos));
47 output.push_back(substr);
59 std::time_t result = std::time(
nullptr);
60 std::ostringstream newm;
62 newm << std::put_time(std::localtime(&result),
"%d/%b/%Y:%H:%M:%S %z");
64 std::tm* time_ = std::localtime(&result);
65 newm << time_->tm_mday <<
"/" << time_->tm_mon <<
"/" << time_->tm_year;
66 newm <<
":" << time_->tm_hour <<
":" << time_->tm_min <<
":"
69 newm <<
" " << type <<
" [";
71 for(
const auto& el : split(input))
75 newm << delimiter << el;
94 dest->AddCoutTransformer(
95 std::bind(&transform, std::placeholders::_1,
"INFO"));
96 dest->AddCerrTransformer(
97 std::bind(&transform, std::placeholders::_1,
"ERROR"));
107 dest->ResetTransformers();
112 std::unordered_map<std::string, SetupStyle_f> transformers = {
113 { ID::SYSLOG, SysLogStyle },
114 { ID::DEFAULT, DefaultStyle }
134 for(
const auto& el : transformers)
136 result.push_back(el.first);
143 const auto& handler = transformers.find(style);
144 return (handler != transformers.cend()) ? (handler->second)(dest) : -1;
149 if(transformers.find(name) != transformers.cend())
152 msg <<
"Format Style with name " << name
153 <<
" already exists. Replacing existing.";
154 G4Exception(
"G4coutFormatters::RegisterNewStyle()",
"FORMATTER001",
158 transformers[name] = fmt;
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
G4GLOB_DLL G4strstreambuf G4coutbuf
G4GLOB_DLL G4strstreambuf G4cerrbuf
void SetDestination(G4coutDestination *dest)