Sorry but I think I'd like to go now.

This commit is contained in:
tildearrow 2022-04-11 00:12:24 -05:00
parent 92b8703574
commit 9e0e725802
6 changed files with 11 additions and 34 deletions

3
.gitmodules vendored
View file

@ -22,6 +22,3 @@
[submodule "extern/Nuked-OPL3"] [submodule "extern/Nuked-OPL3"]
path = extern/Nuked-OPL3 path = extern/Nuked-OPL3
url = https://github.com/nukeykt/Nuked-OPL3.git url = https://github.com/nukeykt/Nuked-OPL3.git
[submodule "extern/date"]
path = extern/date
url = https://github.com/HowardHinnant/date

View file

@ -42,7 +42,6 @@ option(SYSTEM_LIBSNDFILE "Use a system-installed version of libsndfile instead o
option(SYSTEM_RTMIDI "Use a system-installed version of RtMidi instead of the vendored one" OFF) option(SYSTEM_RTMIDI "Use a system-installed version of RtMidi instead of the vendored one" OFF)
option(SYSTEM_ZLIB "Use a system-installed version of zlib instead of the vendored one" OFF) option(SYSTEM_ZLIB "Use a system-installed version of zlib instead of the vendored one" OFF)
option(SYSTEM_SDL2 "Use a system-installed version of SDL2 instead of the vendored one" ${SYSTEM_SDL2_DEFAULT}) option(SYSTEM_SDL2 "Use a system-installed version of SDL2 instead of the vendored one" ${SYSTEM_SDL2_DEFAULT})
option(SYSTEM_DATE "Use a system-installed version of Date instead of the vendored one" OFF)
option(WARNINGS_ARE_ERRORS "Whether warnings in furnace's C++ code should be treated as errors" OFF) option(WARNINGS_ARE_ERRORS "Whether warnings in furnace's C++ code should be treated as errors" OFF)
set(DEPENDENCIES_INCLUDE_DIRS "") set(DEPENDENCIES_INCLUDE_DIRS "")
@ -127,25 +126,6 @@ if (USE_RTMIDI)
endif() endif()
endif() endif()
if (SYSTEM_DATE)
find_package(PkgConfig REQUIRED)
pkg_check_modules(HHDATE REQUIRED date)
list(APPEND DEPENDENCIES_INCLUDE_DIRS ${HHDATE_INCLUDE_DIRS})
list(APPEND DEPENDENCIES_COMPILE_OPTIONS ${HHDATE_CFLAGS_OTHER})
list(APPEND DEPENDENCIES_LIBRARIES ${HHDATE_LIBRARIES})
list(APPEND DEPENDENCIES_LIBRARY_DIRS ${HHDATE_LIBRARY_DIRS})
list(APPEND DEPENDENCIES_LINK_OPTIONS ${HHDATE_LDFLAGS_OTHER})
list(APPEND DEPENDENCIES_LEGACY_LDFLAGS ${HHDATE_LDFLAGS})
message(STATUS "Using system-installed Date")
else()
set(BUILD_TZ_LIB ON CACHE BOOL "build/install of TZ library" FORCE)
set(USE_SYSTEM_TZ_DB ON CACHE BOOL "Fix the build already" FORCE)
add_subdirectory(extern/date EXCLUDE_FROM_ALL)
list(APPEND DEPENDENCIES_INCLUDE_DIRS extern/date/include)
list(APPEND DEPENDENCIES_LIBRARIES date date-tz)
message(STATUS "Using vendored Date")
endif()
if (SYSTEM_ZLIB) if (SYSTEM_ZLIB)
find_package(PkgConfig REQUIRED) find_package(PkgConfig REQUIRED)
pkg_check_modules(ZLIB REQUIRED zlib) pkg_check_modules(ZLIB REQUIRED zlib)

1
extern/date vendored

@ -1 +0,0 @@
Subproject commit 9ea5654c1206e19245dc21d8a2c433e090c8c3f5

View file

@ -1,7 +1,5 @@
#include "gui.h" #include "gui.h"
#include "../ta-log.h" #include "../ta-log.h"
#include <chrono>
#include "date/tz.h"
const char* logLevels[5]={ const char* logLevels[5]={
"ERROR", "ERROR",
@ -56,11 +54,9 @@ void FurnaceGUI::drawLog() {
const LogEntry& logEntry=logEntries[(pos+i)&(TA_LOG_SIZE-1)]; const LogEntry& logEntry=logEntries[(pos+i)&(TA_LOG_SIZE-1)];
if (!logEntry.ready) continue; if (!logEntry.ready) continue;
if (logLevel<logEntry.loglevel) continue; if (logLevel<logEntry.loglevel) continue;
String t=date::format("%T",date::make_zoned(date::current_zone(),date::floor<std::chrono::seconds>(logEntry.time)));
ImGui::TableNextRow(); ImGui::TableNextRow();
ImGui::TableNextColumn(); ImGui::TableNextColumn();
// this will fail on 32-bit :< ImGui::Text("%02d:%02d:%02d",logEntry.time.tm_hour,logEntry.time.tm_min,logEntry.time.tm_sec);
ImGui::TextUnformatted(t.c_str());
ImGui::TableNextColumn(); ImGui::TableNextColumn();
ImGui::TextColored(uiColors[logColors[logEntry.loglevel]],"%s",logLevels[logEntry.loglevel]); ImGui::TextColored(uiColors[logColors[logEntry.loglevel]],"%s",logLevels[logEntry.loglevel]);
ImGui::TableNextColumn(); ImGui::TableNextColumn();
@ -75,4 +71,4 @@ void FurnaceGUI::drawLog() {
} }
} }
ImGui::End(); ImGui::End();
} }

View file

@ -90,11 +90,16 @@ int logE(const char* format, ...) {
} }
int writeLog(int level, const char* msg, fmt::printf_args& args) { int writeLog(int level, const char* msg, fmt::printf_args& args) {
time_t thisMakesNoSense=time(NULL);
int pos=logPosition; int pos=logPosition;
logPosition=(logPosition+1)&TA_LOG_MASK; logPosition=(logPosition+1)&TA_LOG_MASK;
logEntries[pos].text=fmt::vsprintf(msg,args); logEntries[pos].text=fmt::vsprintf(msg,args);
logEntries[pos].time=std::chrono::system_clock::now(); // why do I have to pass a pointer
// can't I just pass the time_t directly?!
if (localtime_r(&thisMakesNoSense,&logEntries[pos].time)==NULL) {
memset(&logEntries[pos].time,0,sizeof(struct tm));
}
logEntries[pos].loglevel=level; logEntries[pos].loglevel=level;
logEntries[pos].ready=true; logEntries[pos].ready=true;
@ -119,4 +124,4 @@ void initLog() {
for (int i=0; i<TA_LOG_SIZE; i++) { for (int i=0; i<TA_LOG_SIZE; i++) {
logEntries[i].text.reserve(128); logEntries[i].text.reserve(128);
} }
} }

View file

@ -19,9 +19,9 @@
#ifndef _TA_LOG_H #ifndef _TA_LOG_H
#define _TA_LOG_H #define _TA_LOG_H
#include <chrono>
#include <stdio.h> #include <stdio.h>
#include <stdarg.h> #include <stdarg.h>
#include <time.h>
#include <atomic> #include <atomic>
#include <string> #include <string>
#include <fmt/printf.h> #include <fmt/printf.h>
@ -41,7 +41,7 @@ extern std::atomic<unsigned short> logPosition;
struct LogEntry { struct LogEntry {
int loglevel; int loglevel;
std::chrono::system_clock::time_point time; struct tm time;
std::string text; std::string text;
bool ready; bool ready;
LogEntry(): LogEntry():