Belle II Software development
Belle2::IOIntercept Namespace Reference

Encapsulate all classes needed to intercept stdout and stderr. More...

Classes

class  CaptureStream
 Class to capture anything written to stream into a string. More...
 
class  CaptureStreamAbortHandler
 Small class to handle std::abort() calls by external libraries. More...
 
class  DiscardStream
 Simple class to just discard anything written to stream by redirecting it to /dev/null. More...
 
class  InterceptorScopeGuard
 Simple RAII guard for output interceptor. More...
 
class  InterceptOutput
 Class to intercept stdout and stderr and either capture, discard or keep them unmodified depending on the template arguments. More...
 
class  KeepStream
 Dummy class which keeps the stream unmodified. More...
 
class  OutputToLogMessages
 Capture stdout and stderr and convert into log messages. More...
 
class  StreamInterceptor
 Base class with all necessary features to intercept output to a file descriptor. More...
 

Typedefs

using CaptureStdOutStdErr = InterceptOutput< CaptureStream, CaptureStream >
 Capture both stdout and stderr as strings.
 
using CaptureStdOut = InterceptOutput< CaptureStream, KeepStream >
 Capture only stdout and don't modify stderr.
 
using CaptureStdErr = InterceptOutput< KeepStream, CaptureStream >
 Capture only stderr and don't modify stdout.
 
using DiscardStdOutStdErr = InterceptOutput< DiscardStream, DiscardStream >
 Discard both stdout and stderr.
 
using DiscardStdOut = InterceptOutput< DiscardStream, KeepStream >
 Discard only stdout and don't modify stderr.
 
using DiscardStdErr = InterceptOutput< KeepStream, DiscardStream >
 Discard only stderr and don't modify stdout.
 
using CaptureStdOutDiscardStdErr = InterceptOutput< CaptureStream, DiscardStream >
 Capture stdout and discard stderr.
 
using DiscardStdOutCaptureStdErr = InterceptOutput< DiscardStream, CaptureStream >
 Capture stderr and discard stdout.
 

Functions

template<class T >
InterceptorScopeGuard< T > start_intercept (T &interceptor)
 Convenience wrapper to simplify use of InterceptorScopeGuard<T>.
 

Detailed Description

Encapsulate all classes needed to intercept stdout and stderr.

Typedef Documentation

◆ CaptureStdErr

Capture only stderr and don't modify stdout.

Definition at line 184 of file IOIntercept.h.

◆ CaptureStdOut

Capture only stdout and don't modify stderr.

Definition at line 182 of file IOIntercept.h.

◆ CaptureStdOutDiscardStdErr

Capture stdout and discard stderr.

Definition at line 192 of file IOIntercept.h.

◆ CaptureStdOutStdErr

Capture both stdout and stderr as strings.

Definition at line 180 of file IOIntercept.h.

◆ DiscardStdErr

Discard only stderr and don't modify stdout.

Definition at line 190 of file IOIntercept.h.

◆ DiscardStdOut

Discard only stdout and don't modify stderr.

Definition at line 188 of file IOIntercept.h.

◆ DiscardStdOutCaptureStdErr

Capture stderr and discard stdout.

Definition at line 194 of file IOIntercept.h.

◆ DiscardStdOutStdErr

Discard both stdout and stderr.

Definition at line 186 of file IOIntercept.h.

Function Documentation

◆ start_intercept()

InterceptorScopeGuard< T > start_intercept ( T &  interceptor)

Convenience wrapper to simplify use of InterceptorScopeGuard<T>.

This function will return the correct scope guard without the need to specify the template parameter.

IOIntercept::OutputToLogMessages iointercept("myinterceptor");
if(needIntercept){
auto guard = IOIntercept::start_intercept(iointercept);
// while the variable guard is in scope the intercept will be active
}
// intercept will be disabled here
Capture stdout and stderr and convert into log messages.
Definition: IOIntercept.h:226
InterceptorScopeGuard< T > start_intercept(T &interceptor)
Convenience wrapper to simplify use of InterceptorScopeGuard<T>.
Definition: IOIntercept.h:345
Parameters
interceptorthe interceptor object to use, must stay valid during the lifetime of the returned object.

Definition at line 345 of file IOIntercept.h.

346 {
347 return InterceptorScopeGuard<T> {interceptor};
348 }
Simple RAII guard for output interceptor.
Definition: IOIntercept.h:301