Commit 0b094fe3 authored by Libretro-Admin's avatar Libretro-Admin
Browse files

Rename ConsoleListener.cpp to ConsoleListenerLibretro, and stub

out FileListener code entirely, and add __LIBRETRO__ ifdefs
parent 5e4bd4e5
Pipeline #16332 passed with stages
in 2 minutes and 19 seconds
......@@ -79,7 +79,7 @@ SOURCES_CXX := \
$(CORE_DIR)/core/imgread/common.cpp \
$(CORE_DIR)/core/imgread/cue.cpp \
$(CORE_DIR)/core/imgread/gdi.cpp \
$(CORE_DIR)/core/log/ConsoleListener.cpp \
$(CORE_DIR)/core/log/ConsoleListenerLibretro.cpp \
$(CORE_DIR)/core/log/LogManager.cpp \
\
$(CORE_DIR)/core/cheats.cpp \
......
......@@ -5,12 +5,11 @@
#include <unistd.h>
#endif
#include "ConsoleListener.h"
#include "ConsoleListenerLibretro.h"
#include "Log.h"
ConsoleListener::ConsoleListener(void *log_cb)
{
m_use_color = false;
retro_printf = (retro_log_printf_t)log_cb;
}
......@@ -40,8 +39,4 @@ void ConsoleListener::Log(LogTypes::LOG_LEVELS level, const char* text)
}
if (retro_printf != nullptr)
retro_printf(retro_level, "%s", text);
#if 0
else
printf("%s\n", text);
#endif
}
......@@ -5,7 +5,7 @@
#pragma once
#include "LogManager.h"
#include "libretro-common/include/libretro.h"
#include <libretro.h>
class ConsoleListener : public LogListener
{
......@@ -16,6 +16,5 @@ public:
void Log(LogTypes::LOG_LEVELS, const char* text) override;
private:
bool m_use_color;
retro_log_printf_t retro_printf = nullptr;
};
......@@ -8,17 +8,26 @@
#include <cstdarg>
#include <cstring>
#include <locale>
#ifndef __LIBRETRO__
#include <mutex>
#include <ostream>
#endif
#include <string>
#ifndef __LIBRETRO__
#include <fstream>
#endif
#ifdef __LIBRETRO__
#include "ConsoleListenerLibretro.h"
#else
#include "ConsoleListener.h"
#endif
#include "Log.h"
#include "StringUtil.h"
constexpr size_t MAX_MSGLEN = 1024;
#ifndef __LIBRETRO__
template <typename T>
void OpenFStream(T& fstream, const std::string& filename, std::ios_base::openmode openmode)
{
......@@ -56,6 +65,7 @@ private:
std::ofstream m_logfile;
bool m_enable;
};
#endif
void GenericLog(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, const char* file, int line,
const char* fmt, ...)
......@@ -112,7 +122,9 @@ LogManager::LogManager(void *log_cb)
m_log[LogTypes::SAVESTATE] = {"SAVESTATE", "Save States"};
m_log[LogTypes::SH4] = {"SH4", "SH4 Modules"};
// RegisterListener(LogListener::FILE_LISTENER, new FileLogListener("flycast.log"));
#ifndef __LIBRETRO__
RegisterListener(LogListener::FILE_LISTENER, new FileLogListener("flycast.log"));
#endif
RegisterListener(LogListener::CONSOLE_LISTENER, new ConsoleListener(log_cb));
// Set up log listeners
......@@ -125,9 +137,13 @@ LogManager::LogManager(void *log_cb)
verbosity = MAX_LOGLEVEL;
SetLogLevel(static_cast<LogTypes::LOG_LEVELS>(verbosity));
// EnableListener(LogListener::FILE_LISTENER, false);
#ifndef __LIBRETRO__
EnableListener(LogListener::FILE_LISTENER, false);
#endif
EnableListener(LogListener::CONSOLE_LISTENER, true);
// EnableListener(LogListener::LOG_WINDOW_LISTENER, Config::Get(LOGGER_WRITE_TO_WINDOW));
#ifndef __LIBRETRO__
EnableListener(LogListener::LOG_WINDOW_LISTENER, Config::Get(LOGGER_WRITE_TO_WINDOW));
#endif
for (LogContainer& container : m_log)
{
......@@ -141,7 +157,9 @@ LogManager::~LogManager()
{
// The log window listener pointer is owned by the GUI code.
delete m_listeners[LogListener::CONSOLE_LISTENER];
// delete m_listeners[LogListener::FILE_LISTENER];
#ifndef __LIBRETRO__
delete m_listeners[LogListener::FILE_LISTENER];
#endif
}
// Return the current time formatted as Minutes:Seconds:Milliseconds
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment