Grassroots Infrastructure
The Grassroots Infrastructure is a suite of computing tools to help users and developers use scientific data infrastructure that can easily be interconnected.
OutputStream Struct Reference

An datatype to abstract out the process of writing log and error messages to the appropriate processes and places on a given Server. More...

#include <streams.h>

Inheritance diagram for OutputStream:
[legend]

Public Member Functions

void FreeDefaultOutputStream (void)
 Free the default OutputStreams. More...
 
void SetDefaultErrorStream (OutputStream *stream_p)
 Set the Server-side OutputStream for printing error messages to. More...
 
void SetDefaultLogStream (OutputStream *stream_p)
 Set the Server-side OutputStream for printing error messages to. More...
 
void FreeOutputStream (struct OutputStream *stream_p)
 Free an OutputStream. More...
 
int PrintToOutputStream (OutputStream *stream_p, const char *const filename_s, const int line_number, const char *message_s,...)
 Print to a given error OutputStream. More...
 
int PrintErrors (const uint32 level, const char *const filename_s, const int line_number, const char *message,...)
 Print to the error OutputStream. More...
 
int PrintLog (const uint32 level, const char *const filename_s, const int line_number, const char *message_s,...)
 Print to the log OutputStream. More...
 
int PrintErrorsVarArgs (const uint32 level, const char *const filename_s, const int line_number, const char *message_s, va_list args)
 Print to the error OutputStream. More...
 
int PrintLogVarArgs (const uint32 level, const char *const filename_s, const int line_number, const char *message_s, va_list args)
 Print to the log OutputStream. More...
 
OutputStreamGetLogOutput (void)
 Get where logging messages will be sent. More...
 
OutputStreamGetErrorsOutput (void)
 Get where error messages will be sent. More...
 
bool FlushOutputStream (OutputStream *stream_p)
 Flush an OutputStream. More...
 
bool FlushLog (void)
 Flush the logging OutputStream. More...
 
bool FlushErrors (void)
 Flush the errors OutputStream. More...
 

Data Fields

int(* st_print_fn )(struct OutputStream *stream_p, const uint32 level, const char *const filename_s, const int line_number, const char *message_s, va_list args)
 Print to an OutputStream. More...
 
bool(* st_flush_fn )(struct OutputStream *stream_p)
 Flush any pending writes to an OutputStream. More...
 
void(* st_free_stream_fn )(struct OutputStream *stream_p)
 Callback function to free the OutputStream if it needs any custom behaviour. More...
 

Detailed Description

An datatype to abstract out the process of writing log and error messages to the appropriate processes and places on a given Server.

Member Function Documentation

◆ FreeDefaultOutputStream()

void FreeDefaultOutputStream ( void  )

Free the default OutputStreams.

This should be called when stopping a Server.

◆ SetDefaultErrorStream()

void SetDefaultErrorStream ( OutputStream stream_p)

Set the Server-side OutputStream for printing error messages to.

Parameters
stream_pThe OutputStream to use.

◆ SetDefaultLogStream()

void SetDefaultLogStream ( OutputStream stream_p)

Set the Server-side OutputStream for printing error messages to.

Parameters
stream_pThe OutputStream to use.

◆ FreeOutputStream()

void FreeOutputStream ( struct OutputStream stream_p)

Free an OutputStream.

This will call st_free_fn.

Parameters
stream_pThe OutputStream to free

◆ PrintToOutputStream()

int PrintToOutputStream ( OutputStream stream_p,
const char *const  filename_s,
const int  line_number,
const char *  message_s,
  ... 
)

Print to a given error OutputStream.

This will call st_print_fn.

Parameters
stream_pThe OutputStream to print to.
filename_sThe name of the file calling this function.
line_numberThe line in the file from which this function was called.
message_sA char * using the same format as printf, etc.
Returns
On success, the total number of characters written is returned. On failure, a negative number is returned. If the error OutputStream is NULL, then this will return 0.
See also
st_print_fn

◆ PrintErrors()

int PrintErrors ( const uint32  level,
const char *const  filename_s,
const int  line_number,
const char *  message,
  ... 
)

Print to the error OutputStream.

If this has not previously been set, it will default to stderr.

Parameters
levelThe stream level to use.
filename_sThe name of the file calling this function.
line_numberThe line in the file from which this function was called.
messageA char * using the same format as printf, etc.
Returns
On success, the total number of characters written is returned. On failure, a negative number is returned. If the error OutputStream is NULL, then this will return 0.

◆ PrintLog()

int PrintLog ( const uint32  level,
const char *const  filename_s,
const int  line_number,
const char *  message_s,
  ... 
)

Print to the log OutputStream.

If this has not previously been set, it will default to stdout.

Parameters
levelThe stream level to use.
filename_sThe name of the file calling this function.
line_numberThe line in the file from which this function was called.
message_sA char * using the same format as printf, etc.
Returns
On success, the total number of characters written is returned. On failure, a negative number is returned. If the log OutputStream is NULL, then this will return 0.

◆ PrintErrorsVarArgs()

int PrintErrorsVarArgs ( const uint32  level,
const char *const  filename_s,
const int  line_number,
const char *  message_s,
va_list  args 
)

Print to the error OutputStream.

If this has not previously been set, it will default to stderr.

Parameters
levelThe stream level to use.
filename_sThe name of the file calling this function.
line_numberThe line in the file from which this function was called.
message_sA char * using the same format as printf, etc.
argsA va_list of the values to print.
Returns
On success, the total number of characters written is returned. On failure, a negative number is returned. If the error OutputStream is NULL, then this will return 0.

◆ PrintLogVarArgs()

int PrintLogVarArgs ( const uint32  level,
const char *const  filename_s,
const int  line_number,
const char *  message_s,
va_list  args 
)

Print to the log OutputStream.

If this has not previously been set, it will default to stdout.

Parameters
levelThe stream level to use.
filename_sThe name of the file calling this function.
line_numberThe line in the file from which this function was called.
message_sA char * using the same format as printf, etc.
argsA va_list of the values to print.
Returns
On success, the total number of characters written is returned. On failure, a negative number is returned. If the log OutputStream is NULL, then this will return 0.

◆ GetLogOutput()

OutputStream * GetLogOutput ( void  )

Get where logging messages will be sent.

Returns
The OutputStream to send results to.

◆ GetErrorsOutput()

OutputStream * GetErrorsOutput ( void  )

Get where error messages will be sent.

Returns
The OutputStream to send results to.

◆ FlushOutputStream()

bool FlushOutputStream ( OutputStream stream_p)

Flush an OutputStream.

Parameters
stream_pThe OutputStream to flush.
Returns
true if the OutputStream was flushed successfully, falsse otherwise.
See also
st_flush_fn

◆ FlushLog()

bool FlushLog ( void  )

Flush the logging OutputStream.

Returns
true if the logging OutputStream was flushed successfully, falsse otherwise.
See also
FlushOutputStream

◆ FlushErrors()

bool FlushErrors ( void  )

Flush the errors OutputStream.

Returns
true if the errors OutputStream was flushed successfully, falsse otherwise.
See also
FlushOutputStream

Field Documentation

◆ st_print_fn

int(* st_print_fn) (struct OutputStream *stream_p, const uint32 level, const char *const filename_s, const int line_number, const char *message_s, va_list args)

Print to an OutputStream.

Parameters
stream_pThe OutputStream to print to.
levelThe
message_sThe message to print. This can include the standard printf format specifiers.
argsAny arguments to match against the format specifiers.
Returns
If successful, the total number of characters written. If this is negative then an error has occurred.
See also
PrintToOutputStream

◆ st_flush_fn

bool(* st_flush_fn) (struct OutputStream *stream_p)

Flush any pending writes to an OutputStream.

Parameters
stream_pThe OutputStream to flush
Returns
true if the OutputStream was flushed succesfully, false otherwise.

◆ st_free_stream_fn

void(* st_free_stream_fn) (struct OutputStream *stream_p)

Callback function to free the OutputStream if it needs any custom behaviour.

Parameters
stream_pThe OutputStream to free.

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