mirror of
https://github.com/zoriya/ComSquare.git
synced 2026-06-08 04:00:38 +00:00
Creating a logger
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#include "Memory/MemoryBus.hpp"
|
||||
#include "Memory/MemoryShadow.hpp"
|
||||
#include "Exceptions/InvalidAddress.hpp"
|
||||
#include "Models/Logger.hpp"
|
||||
|
||||
namespace ComSquare::Memory
|
||||
{
|
||||
@@ -26,7 +27,7 @@ namespace ComSquare::Memory
|
||||
IMemory *handler = this->getAccessor(addr);
|
||||
|
||||
if (!handler) {
|
||||
std::cout << "Unknown memory accessor for address $" << std::hex << addr << ". Using open bus." << std::endl;
|
||||
log(LogLevel::WARNING, "Unknown memory accessor for address $" << std::hex << addr << ". Using open bus.");
|
||||
return this->_openBus;
|
||||
}
|
||||
|
||||
@@ -61,7 +62,7 @@ namespace ComSquare::Memory
|
||||
IMemory *handler = this->getAccessor(addr);
|
||||
|
||||
if (!handler) {
|
||||
std::cout << "Unknown memory accessor for address " << std::hex << addr << ". Warning, it was a write." << std::endl;
|
||||
log(LogLevel::ERROR, "Unknown memory accessor for address " << std::hex << addr << ". Warning, it was a write.");
|
||||
return;
|
||||
}
|
||||
handler->write(handler->getRelativeAddress(addr), data);
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
//
|
||||
// Created by Zoe Roux on 2021-07-06.
|
||||
//
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#ifdef TESTS
|
||||
#include <catch2/catch.hpp>
|
||||
#endif
|
||||
|
||||
namespace ComSquare
|
||||
{
|
||||
enum LogLevel
|
||||
{
|
||||
INFO,
|
||||
WARNING,
|
||||
ERROR
|
||||
};
|
||||
|
||||
constexpr LogLevel GlobalLevel = INFO;
|
||||
|
||||
#ifndef TESTS
|
||||
#define log(level, message) \
|
||||
if constexpr((level) >= GlobalLevel) \
|
||||
std::cout << message << std::endl // NOLINT(bugprone-macro-parentheses)
|
||||
#else
|
||||
#define log(_, msg) INFO(msg)
|
||||
#endif
|
||||
}
|
||||
@@ -7,12 +7,13 @@
|
||||
#include <QIcon>
|
||||
#include <QMenuBar>
|
||||
#include <iostream>
|
||||
#include "Models/Logger.hpp"
|
||||
#include "SNES.hpp"
|
||||
#include "QtSFML.hpp"
|
||||
|
||||
#ifdef Q_WS_X11
|
||||
#include <Qt/qx11info_x11.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <Qt/qx11info_x11.h>
|
||||
#include <X11/Xlib.h>
|
||||
#endif
|
||||
|
||||
namespace ComSquare::Renderer
|
||||
@@ -57,7 +58,7 @@ namespace ComSquare::Renderer
|
||||
}
|
||||
#ifdef DEBUGGER_ENABLED
|
||||
catch (const DebuggableError &e) {
|
||||
std::cout << "Invalid rom's instruction: " << e.what() << std::endl;
|
||||
log(LogLevel::ERROR, "Invalid rom's instruction: " << e.what());
|
||||
this->_snes.enableCPUDebuggingWithError(e);
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user