Added missing files.

This commit is contained in:
crs 2003-01-05 21:52:28 +00:00
parent e9cc0b434e
commit f832bdaf12
2 changed files with 229 additions and 0 deletions

158
lib/base/LogOutputters.cpp Normal file
View File

@ -0,0 +1,158 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2002 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file COPYING that should have accompanied this file.
*
* This package 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.
*/
#include "LogOutputters.h"
#include "CArch.h"
//
// CStopLogOutputter
//
CStopLogOutputter::CStopLogOutputter()
{
// do nothing
}
CStopLogOutputter::~CStopLogOutputter()
{
// do nothing
}
void
CStopLogOutputter::open(const char*)
{
// do nothing
}
void
CStopLogOutputter::close()
{
// do nothing
}
bool
CStopLogOutputter::write(ELevel, const char*)
{
return false;
}
const char*
CStopLogOutputter::getNewline() const
{
return "";
}
//
// CConsoleLogOutputter
//
CConsoleLogOutputter::CConsoleLogOutputter()
{
// do nothing
}
CConsoleLogOutputter::~CConsoleLogOutputter()
{
// do nothing
}
void
CConsoleLogOutputter::open(const char* title)
{
ARCH->openConsole(title);
}
void
CConsoleLogOutputter::close()
{
ARCH->closeConsole();
}
bool
CConsoleLogOutputter::write(ELevel, const char* msg)
{
ARCH->writeConsole(msg);
return true;
}
const char*
CConsoleLogOutputter::getNewline() const
{
return ARCH->getNewlineForConsole();
}
//
// CSystemLogOutputter
//
CSystemLogOutputter::CSystemLogOutputter()
{
// do nothing
}
CSystemLogOutputter::~CSystemLogOutputter()
{
// do nothing
}
void
CSystemLogOutputter::open(const char* title)
{
ARCH->openLog(title);
}
void
CSystemLogOutputter::close()
{
ARCH->closeLog();
}
bool
CSystemLogOutputter::write(ELevel level, const char* msg)
{
IArchLog::ELevel archLogLevel;
switch (level) {
case CLog::kFATAL:
case CLog::kERROR:
archLogLevel = IArchLog::kERROR;
break;
case CLog::kWARNING:
archLogLevel = IArchLog::kWARNING;
break;
case CLog::kNOTE:
archLogLevel = IArchLog::kNOTE;
break;
case CLog::kINFO:
archLogLevel = IArchLog::kINFO;
break;
default:
archLogLevel = IArchLog::kDEBUG;
break;
};
ARCH->writeLog(archLogLevel, msg);
return true;
}
const char*
CSystemLogOutputter::getNewline() const
{
return "";
}

71
lib/base/LogOutputters.h Normal file
View File

@ -0,0 +1,71 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2002 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file COPYING that should have accompanied this file.
*
* This package 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.
*/
#ifndef LOGOUTPUTTERS_H
#define LOGOUTPUTTERS_H
#include "ILogOutputter.h"
//! Stop traversing log chain outputter
/*!
This outputter performs no output and returns false from \c write(),
causing the logger to stop traversing the outputter chain. Insert
this to prevent already inserted outputters from writing.
*/
class CStopLogOutputter : public ILogOutputter {
public:
CStopLogOutputter();
virtual ~CStopLogOutputter();
// ILogOutputter overrides
virtual void open(const char* title);
virtual void close();
virtual bool write(ELevel level, const char* message);
virtual const char* getNewline() const;
};
//! Write log to console
/*!
This outputter writes output to the console. The level for each
message is ignored.
*/
class CConsoleLogOutputter : public ILogOutputter {
public:
CConsoleLogOutputter();
virtual ~CConsoleLogOutputter();
// ILogOutputter overrides
virtual void open(const char* title);
virtual void close();
virtual bool write(ELevel level, const char* message);
virtual const char* getNewline() const;
};
//! Write log to system log
/*!
This outputter writes output to the system log.
*/
class CSystemLogOutputter : public ILogOutputter {
public:
CSystemLogOutputter();
virtual ~CSystemLogOutputter();
// ILogOutputter overrides
virtual void open(const char* title);
virtual void close();
virtual bool write(ELevel level, const char* message);
virtual const char* getNewline() const;
};
#endif