refactor: remove archConsole use its only implemented method directly in logOutputters

This commit is contained in:
sithlord48
2025-05-16 22:11:30 -04:00
committed by Nick Bolton
parent a9e0c62c24
commit 037fee0e59
8 changed files with 10 additions and 161 deletions

View File

@ -28,7 +28,6 @@
#if SYSAPI_WIN32
#include "arch/win32/ArchConsoleWindows.h"
#include "arch/win32/ArchDaemonWindows.h"
#include "arch/win32/ArchLogWindows.h"
#include "arch/win32/ArchMultithreadWindows.h"
@ -39,7 +38,6 @@
#elif SYSAPI_UNIX
#include "arch/unix/ArchConsoleUnix.h"
#include "arch/unix/ArchDaemonUnix.h"
#include "arch/unix/ArchLogUnix.h"
#include "arch/unix/ArchNetworkBSD.h"
@ -69,8 +67,7 @@ to each method to those implementations. Clients should use the
exactly one of these objects before attempting to call any method,
typically at the beginning of \c main().
*/
class Arch : public ARCH_CONSOLE,
public ARCH_DAEMON,
class Arch : public ARCH_DAEMON,
public ARCH_LOG,
public ARCH_MULTITHREAD,
public ARCH_NETWORK,

View File

@ -1,21 +0,0 @@
/*
* Deskflow -- mouse and keyboard sharing utility
* SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd.
* SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
*/
#include "arch/ArchConsoleStd.h"
#include "base/Log.h"
#include <iostream>
void ArchConsoleStd::writeConsole(ELevel level, const char *str)
{
if ((level >= kFATAL) && (level <= kWARNING))
std::cerr << str << std::endl;
else
std::cout << str << std::endl;
std::cout.flush();
}

View File

@ -1,33 +0,0 @@
/*
* Deskflow -- mouse and keyboard sharing utility
* SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd.
* SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
*/
#pragma once
#include "arch/IArchConsole.h"
//! Cross platform implementation of IArchConsole
class ArchConsoleStd : public IArchConsole
{
public:
ArchConsoleStd() = default;
~ArchConsoleStd() override = default;
// IArchConsole overrides
void openConsole(const char *title) override
{
// do nothing
}
void closeConsole() override
{
// do nothing
}
void showConsole(bool) override
{
// do nothing
}
void writeConsole(ELevel level, const char *) override;
};

View File

@ -6,7 +6,6 @@
# Platform Specific Code
if(WIN32)
set(PLATFORM_CODE
win32/ArchConsoleWindows.h
win32/ArchDaemonWindows.cpp
win32/ArchDaemonWindows.h
win32/ArchLogWindows.cpp
@ -29,7 +28,6 @@ if(WIN32)
elseif(UNIX)
set(PLATFORM_CODE
unix/ArchConsoleUnix.h
unix/ArchDaemonUnix.cpp
unix/ArchDaemonUnix.h
unix/ArchLogUnix.cpp
@ -52,11 +50,8 @@ endif()
add_library(arch STATIC ${PLATFORM_CODE}
Arch.cpp
Arch.h
ArchConsoleStd.cpp
ArchConsoleStd.h
ArchDaemonNone.cpp
ArchDaemonNone.h
IArchConsole.h
IArchDaemon.h
IArchLog.h
IArchMultithread.h

View File

@ -1,56 +0,0 @@
/*
* Deskflow -- mouse and keyboard sharing utility
* SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd.
* SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
*/
#pragma once
#include "base/ELevel.h"
#include "common/IInterface.h"
//! Interface for architecture dependent console output
/*!
This interface defines the console operations required by
deskflow. Each architecture must implement this interface.
*/
class IArchConsole : public IInterface
{
public:
//! @name manipulators
//@{
//! Open the console
/*!
Opens the console for writing. The console is opened automatically
on the first write so calling this method is optional. Uses \c title
for the console's title if appropriate for the architecture. Calling
this method on an already open console must have no effect.
*/
virtual void openConsole(const char *title) = 0;
//! Close the console
/*!
Close the console. Calling this method on an already closed console
must have no effect.
*/
virtual void closeConsole() = 0;
//! Show the console
/*!
Causes the console to become visible. This generally only makes sense
for a console in a graphical user interface. Other implementations
will do nothing. Iff \p showIfEmpty is \c false then the implementation
may optionally only show the console if it's not empty.
*/
virtual void showConsole(bool showIfEmpty) = 0;
//! Write to the console
/*!
Writes the given string to the console, opening it if necessary.
*/
virtual void writeConsole(ELevel, const char *) = 0;
//@}
};

View File

@ -1,19 +0,0 @@
/*
* Deskflow -- mouse and keyboard sharing utility
* SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd.
* SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
*/
#pragma once
#include "arch/ArchConsoleStd.h"
#define ARCH_CONSOLE ArchConsoleUnix
class ArchConsoleUnix : public ArchConsoleStd
{
public:
ArchConsoleUnix() = default;
~ArchConsoleUnix() override = default;
};

View File

@ -1,19 +0,0 @@
/*
* Deskflow -- mouse and keyboard sharing utility
* SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd.
* SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
*/
#pragma once
#include "arch/ArchConsoleStd.h"
#define ARCH_CONSOLE ArchConsoleWindows
class ArchConsoleWindows : public ArchConsoleStd
{
public:
ArchConsoleWindows() = default;
~ArchConsoleWindows() override = default;
};

View File

@ -12,6 +12,7 @@
#include "base/String.h"
#include <fstream>
#include <iostream>
enum EFileLogOutputter
{
@ -48,22 +49,26 @@ bool StopLogOutputter::write(ELevel, const char *)
void ConsoleLogOutputter::open(const char *title)
{
ARCH->openConsole(title);
// do nothing
}
void ConsoleLogOutputter::close()
{
ARCH->closeConsole();
// do nothing
}
void ConsoleLogOutputter::show(bool showIfEmpty)
{
ARCH->showConsole(showIfEmpty);
// do nothing
}
bool ConsoleLogOutputter::write(ELevel level, const char *msg)
{
ARCH->writeConsole(level, msg);
if ((level >= kFATAL) && (level <= kWARNING))
std::cerr << msg << std::endl;
else
std::cout << msg << std::endl;
std::cout.flush();
return true;
}