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 }
133 for(
const auto& el : transformers)
135 result.push_back(el.first);
142 const auto& handler = transformers.find(style);
143 return (handler != transformers.cend()) ? (handler->second)(dest) : -1;
148 if(transformers.find(name) != transformers.cend())
151 msg <<
"Format Style with name " << name
152 <<
" already exists. Replacing existing.";
153 G4Exception(
"G4coutFormatters::RegisterNewStyle()",
"FORMATTER001",
157 transformers[name] = fmt;
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
void G4iosSetDestination(G4coutDestination *sink)