DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
StreamManager.cpp File Reference
#include <assert.h>
#include <iostream>
#include <ers/Issue.hpp>
#include <ers/InputStream.hpp>
#include <ers/OutputStream.hpp>
#include <ers/StreamManager.hpp>
#include <ers/StreamFactory.hpp>
#include <ers/Severity.hpp>
#include <ers/Configuration.hpp>
#include <ers/ers.hpp>
#include <ers/internal/macro.hpp>
#include <ers/internal/Util.hpp>
#include <ers/internal/PluginManager.hpp>
#include <ers/internal/NullStream.hpp>
#include <ers/internal/SingletonCreator.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.

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