OutputLog.hpp File Reference

The logging is implemented using two maps. More...

#include <iosfwd>
#include <string>

Go to the source code of this file.

Namespaces

namespace  stk
 

Sierra Toolkit.


Typedefs

typedef
stk::basic_tee_streambuf< char,
std::char_traits< char > > 
stk::tee_streambuf
 Tee stream buffer for char.

Functions

void stk::register_ostream (std::ostream &os, const std::string &name)
 Function register_ostream registers an output stream with the output stream registry.
void stk::unregister_ostream (std::ostream &os)
 Function unregister_ostream unregisters an output stream.
void stk::bind_output_streams (const std::string &output_description)
 Function bind_output_streams parses the output_description and opens and registers the log streams and binds the registered output streams to the registered log streams.
void stk::register_log_ostream (std::ostream &os, const std::string &name)
 Function register_log_ostream takes an existing std::ostream and makes it available for output redirection.
void stk::unregister_log_ostream (std::ostream &os)
 Function register_log_ostream takes an existing std::ostream and makes it available for output redirection.
void stk::create_log_file (const std::string &name, const std::string &path)
 Function create_log_file opens a log file at the specified path and adds it to the registry of log files with the specified name.
void stk::close_log_file (const std::string &name)
 Function close_log_file close the log file with the specified name and removes it from the registry of log files.
bool stk::is_registered_ostream (const std::string &name)
 Function is_registered_ostream returns true if an output stream of the specified name is registered.
const std::string & stk::get_log_path (const std::string &name)
 Function get_log_path returns the file path of the log file with the specified name from the log file registry.
std::ostream * stk::get_log_ostream (const std::string &name)
 Function get_log_file_ostream return the output stream of the log file with the specified name from the log registry.
std::ostream * stk::get_ostream_ostream (const std::string &name)
 Function get_ostream_streambuf locates the output stream registered with the specified name.
std::ostream * stk::get_ostream_tee_ostream (const std::string &name)
 Function get_ostream_tee_streambuf locates the tee streambuf registered with the specified name.

Detailed Description

The logging is implemented using two maps.

One maps names to log files and streams and one maps names to output streams. Log files and streams are the ultimate destinations for output. The output streams are the data providers. The output streams may also serve as destinations streams, passing stream data to their destinations.

To implement this strategy, the output streams, once registered, create a tee streambuf and attach this as the rdbuf of the registered stream. The original streambuf becomes the destination of the tee streambuf. The tee streambuf sinks data from a stream and sources it to all of its destination streambufs just as the tee utility tees input from stdin to a file set and stdout.

The tee streambuf class provides functions to add and remove destination streams.

When a output stream is unregistered, the tee streambuf is destroyed and the streams original streambuf is restored.

The bind_output_streams() function provides string commands to control the sinks and sources of the log file streams and the output streams.

The functions using ostreams could be converted to templates of Ch and std::char_traits<Ch>.

Definition in file OutputLog.hpp.

Generated on Wed Apr 13 10:05:49 2011 for Sierra Toolkit by  doxygen 1.6.3