MCPcopy Create free account
hub / github.com/OpenMS/OpenMS / configure

Method configure

src/openms/source/CONCEPT/LogConfigHandler.cpp:74–215  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

72 }
73
74 void LogConfigHandler::configure(const Param & param)
75 {
76 StringList configurations = ListUtils::toStringList<std::string>(param.getValue(LogConfigHandler::PARAM_NAME));
77
78 for (StringList::const_iterator iter = configurations.begin(); iter != configurations.end(); ++iter)
79 {
80 // split by " " to get the commands
81 StringList commands;
82 iter->split(' ', commands, true);
83
84 Logger::LogStream & log = getLogStreamByName_(commands[0]);
85
86 // convenience variables
87 String & command = commands[1];
88
89 // identify action
90 if (command == "add")
91 {
92 // convenience variables
93 const String & stream_name = commands[2];
94
95 // add the stream given by the 3rd argument to the defined log
96 if (stream_name == "cout")
97 {
98 log.insert(cout);
99 }
100 else if (stream_name == "cerr")
101 {
102 log.insert(cerr);
103 }
104 else
105 {
106 if (commands.size() <= 3) // write error to cerr and not a LogStream (because we're just configuring it...)
107 {
108 std::cerr << "Error during configuring logging: the command '" << (*iter) << "' requires 4 entries but has only " << commands.size() << "\n";
109 continue;
110 }
111 const String & stream_type = commands[3];
112
113 // check if a stream with the same name, but different type was already registered
114 if (stream_type_map_.count(stream_name) != 0)
115 {
116 if (stream_type_map_[stream_name] != getStreamTypeByName_(stream_type))
117 {
118 throw Exception::IllegalArgument(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "A stream with the same name but different type was already registered.");
119 }
120 }
121
122 StreamHandler::StreamType type = getStreamTypeByName_(stream_type);
123 Int status = STREAM_HANDLER.registerStream(type, stream_name);
124
125 if (!status)
126 {
127 // operation failed
128 throw Exception::FileNotWritable(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, commands[2]);
129 }
130
131 log.insert(STREAM_HANDLER.getStream(type, stream_name));

Callers 1

Calls 14

countMethod · 0.80
registerStreamMethod · 0.80
setPrefixMethod · 0.80
hasStreamMethod · 0.80
unregisterStreamMethod · 0.80
getValueMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
splitMethod · 0.45
insertMethod · 0.45
sizeMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected