log_stream.cpp
Go to the documentation of this file.
/*
CLAW - a C++ Library Absolutely Wonderful
CLAW is a free library without any particular aim but being useful to
anyone.
Copyright (C) 2005-2011 Julien Jorge
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
contact: julien.jorge@gamned.org
*/
#include <claw/log_stream.hpp>
#include <iostream>
/*----------------------------------------------------------------------------*/
claw::log_stream::~log_stream()
{
// nothing to do
} // log_stream::~log_stream()
/*----------------------------------------------------------------------------*/
void claw::log_stream::flush()
{
// nothing to do
} // log_stream::flush()
/*----------------------------------------------------------------------------*/
void claw::console_logger::write( const std::string& str )
{
std::clog << str;
} // console_logger::write()
/*----------------------------------------------------------------------------*/
void claw::console_logger::flush()
{
std::clog.flush();
} // console_logger::flush()
/*----------------------------------------------------------------------------*/
claw::file_logger::file_logger( const std::string& filename )
{
m_file = new std::ofstream( filename.c_str() );
} // file_logger::file_logger()
/*----------------------------------------------------------------------------*/
claw::file_logger::~file_logger()
{
delete m_file;
} // file_logger::~file_logger()
/*----------------------------------------------------------------------------*/
void claw::file_logger::write( const std::string& str )
{
(*m_file) << str;
} // file_logger::write()
/*----------------------------------------------------------------------------*/
void claw::file_logger::flush()
{
m_file->flush();
} // file_logger::flush()
claw::console_logger::write
virtual void write(const std::string &str)
Write a string in the stream.
Definition log_stream.cpp:58
claw::console_logger::flush
virtual void flush()
Flush the stream.
Definition log_stream.cpp:67
claw::file_logger::flush
virtual void flush()
Flush the stream.
Definition log_stream.cpp:106
claw::file_logger::write
virtual void write(const std::string &str)
Write a string in the file.
Definition log_stream.cpp:97
claw::file_logger::~file_logger
virtual ~file_logger()
Destructor.
Definition log_stream.cpp:88
claw::file_logger::file_logger
file_logger(const std::string &filename)
Constructor.
Definition log_stream.cpp:79
claw::log_stream::~log_stream
virtual ~log_stream()
Destructor.
Definition log_stream.cpp:37
claw::log_stream::flush
virtual void flush()
Flush the stream.
Definition log_stream.cpp:46
log_stream.hpp
Some basic classes for logging.