Update of /cvsroot/pclasses/pclasses2/plugins/LogTarget/file
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18557/plugins/LogTarget/file
Added Files:
Makefile.am LogTarget_file.cpp
Log Message:
- Renamed LogTarget plugins
--- NEW FILE: Makefile.am ---
INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include $(all_includes)
METASOURCES = AUTO
pkglib_LTLIBRARIES = LogTarget_file.la
LogTarget_file_la_SOURCES = LogTarget_file.cpp
LogTarget_file_la_LDFLAGS = -module -avoid-version
LogTarget_file_la_LIBADD = $(top_builddir)/src/libpclasses.la \
$(top_builddir)/src/Unicode/libpclasses_unicode.la \
$(top_builddir)/src/IO/libpclasses_io.la \
$(top_builddir)/src/System/libpclasses_system.la \
$(top_builddir)/src/App/libpclasses_app.la
--- NEW FILE: LogTarget_file.cpp ---
/***************************************************************************
* Copyright (C) 2005 by Christian Prochnow, SecuLogiX GmbH *
* cp...@se... *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Library General Public License as *
* published by the Free Software Foundation; either version 2 of the *
* License, or (at your option) any later version. *
* *
* This program 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 General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "pclasses/IO/IOStream.h"
#include "pclasses/System/File.h"
#include "pclasses/System/Plugin.h"
#include "pclasses/App/LogTarget.h"
#include <iostream>
using namespace P;
using namespace P::IO;
using namespace P::System;
using namespace P::App;
using namespace std;
class LogTarget_file: public LogTarget {
public:
LogTarget_file()
: _file(), _out(0)
{
}
~LogTarget_file() throw()
{
if(_out)
delete _out;
}
void open(const URL& url) throw(IOError)
{
_file.open(url.path(), IODevice::Write, IODevice::OpenCreate,
IODevice::AllowRead);
_out = new IOStream(_file);
}
void close() throw(IOError)
{
_file.close();
delete _out;
}
void reload() throw(IOError)
{
}
void output(const LogMessage& msg) throw(IOError)
{
(*_out) << msg.when() << ' ' << msg.level2Str(msg.level()) << ' ' << msg.msg().utf8() << endl;
}
bool valid() const throw()
{
return _file.valid();
}
private:
File _file;
IOStream* _out;
};
P_PLUGIN_REGISTER_TYPE(LogTarget, LogTarget_file);
P_PLUGIN_REGISTER_ALIAS(LogTarget, file, LogTarget_file);
|