gelfcpp::GelfMessageStream Struct Reference

Allows stream like sending of GelfMessage. More...

#include <GelfMessageStream.hpp>

Public Member Functions

template<typename T >
 GelfMessageStream (T &&output)
 Creates a new stream. More...
 
 operator bool ()
 Checks if this stream is associated to a valid output. More...
 
template<typename T >
detail::Sender< std::decay_t< T > > Send (T &&output)
 Opens a stream to an output. More...
 

Detailed Description

Allows stream like sending of GelfMessage.

Usually used in conjunction with a convenience macro like GELF_MESSAGE to allow conditional sending.

Allows contextual-conversion to bool to check wether the output is valid. An output is valid if it can accept messages, meaning:

  • output is a reference to an output type
  • output is a non-null pointer to an output type
  • output is a valid smart pointer (shared, unique) to an output type
Note
Send explicitly requires to provide the output again, since it is not stored inside the stream. This is due to the need to support arbitrary, non-virtual output types.

Usage example:

GelfMessageStream stream(output);
if (stream)
{
stream.Send(output) = message;
// or
stream.Send(output) << message_1 << message_2;
}

Constructor & Destructor Documentation

template<typename T >
gelfcpp::GelfMessageStream::GelfMessageStream ( T &&  output)
inlineexplicit

Creates a new stream.

Checks wether the output is valid and thus invalidates this stream.

Template Parameters
Toutput type
Parameters
outputoutput

Member Function Documentation

gelfcpp::GelfMessageStream::operator bool ( )
inlineexplicit

Checks if this stream is associated to a valid output.

Returns
true if output is valid, false otherwise
template<typename T >
detail::Sender<std::decay_t<T> > gelfcpp::GelfMessageStream::Send ( T &&  output)
inline

Opens a stream to an output.

Note
After calling Send() once this stream is considered invalid.
Template Parameters
Toutput type
Parameters
outputoutput
Returns
Sink for GelfMessages, which are send to the output

The documentation for this struct was generated from the following file: