DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
StreamManager.cpp File Reference
#include <assert.h>
#include <iostream>
#include <ers/Configuration.hpp>
#include <ers/InputStream.hpp>
#include <ers/Issue.hpp>
#include <ers/OutputStream.hpp>
#include <ers/Severity.hpp>
#include <ers/StreamFactory.hpp>
#include <ers/StreamManager.hpp>
#include <ers/ers.hpp>
#include <ers/internal/NullStream.hpp>
#include <ers/internal/PluginManager.hpp>
#include <ers/internal/SingletonCreator.hpp>
#include <ers/internal/Util.hpp>
#include <ers/internal/macro.hpp>
Include dependency graph for StreamManager.cpp:

Go to the source code of this file.

Classes

class  ers::StreamInitializer

Namespaces

namespace  ers

Functions

 ERS_DECLARE_ISSUE (ers, BadConfiguration, "The stream configuration string \""<< config<< "\" has syntax errors.",((std::string) config)) namespace

Function Documentation

◆ ERS_DECLARE_ISSUE()

ERS_DECLARE_ISSUE ( ers ,
BadConfiguration ,
"The stream configuration string \""<< config<< "\" has syntax errors." ,
((std::string) config)  )

This variable contains the default keys for building the default streams. The default is to use the default stream, in verbose mode for errors and fatals.

Definition at line 39 of file StreamManager.cpp.

44 {
48const char SEPARATOR = ',';
49
50const char* const DefaultOutputStreams[] = {
51 "lstdout", // Debug
52 "lstdout", // Log
53 "throttle,lstdout", // Information
54 "throttle,lstderr", // Warning
55 "throttle,lstderr", // Error
56 "lstderr" // Fatal
57};
58
59const char*
60get_stream_description(ers::severity severity)
61{
62 assert(ers::Debug <= severity && severity <= ers::Fatal);
63
64 std::string env_name("DUNEDAQ_ERS_");
65 env_name += ers::to_string(severity);
66 const char* env = ::getenv(env_name.c_str());
67 return env ? env : DefaultOutputStreams[severity];
68}
69
70void
71parse_stream_definition(const std::string& text, std::vector<std::string>& result)
72{
73 std::string::size_type start_p = 0, end_p = 0;
74 short brackets_open = 0;
75 while (end_p < text.length()) {
76 switch (text[end_p]) {
77 case '(':
78 ++brackets_open;
79 break;
80 case ')':
81 --brackets_open;
82 break;
83 case SEPARATOR:
84 if (!brackets_open) {
85 result.push_back(text.substr(start_p, end_p - start_p));
86 start_p = end_p + 1;
87 }
88 break;
89 default:
90 break;
91 }
92 end_p++;
93 }
94 if (brackets_open) {
95 throw ers::BadConfiguration(ERS_HERE, text);
96 }
97 if (start_p != end_p) {
98 result.push_back(text.substr(start_p, end_p - start_p));
99 }
100}
101}
#define ERS_HERE
std::string to_string(severity s)
severity
Definition Severity.hpp:37
@ Debug
Definition Severity.hpp:38
@ Fatal
Definition Severity.hpp:43